From 27a8cbb016dc5772e10c775ff5edc5fd5b4c4e80 Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Fri, 6 Mar 2020 13:53:36 +0800 Subject: [PATCH 1/6] Fix mirroring in mapper 200 --- src/boards/addrlatch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/boards/addrlatch.c b/src/boards/addrlatch.c index 41ef1c1..e3dba77 100644 --- a/src/boards/addrlatch.c +++ b/src/boards/addrlatch.c @@ -266,7 +266,7 @@ static void M200Sync(void) { setprg16(0x8000, latche & 7); setprg16(0xC000, latche & 7); setchr8(latche & 7); - setmirror((latche & 8) >> 3); + setmirror(((latche >> 3) & 1) ^ 1); } void Mapper200_Init(CartInfo *info) { From c4e230ecb4416af43f19607004f263eeb8ed5dab Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Fri, 6 Mar 2020 13:54:14 +0800 Subject: [PATCH 2/6] Update ines-correct.h --- src/ines-correct.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ines-correct.h b/src/ines-correct.h index faecd7b..4a54218 100644 --- a/src/ines-correct.h +++ b/src/ines-correct.h @@ -398,6 +398,7 @@ {0xa1dc16c0, 262, -1}, /* Street Heroes (Asia) (Ja) (Unl */ {0x1df10182, 263, -1}, /* Boogerman II (Rex-Soft) [!].nes */ {0xf956fcea, 521, -1}, /* Korean Igo (Korea) (Unl) */ + {0x2EED2E34, 289, -1}, /* 76-in-1 [p1][a1].nes 2048 PRG, 0 CHR */ {0x00000000, -1, -1} From b2e6d27f9a9e83133aa2d794120fd045ed08e818 Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Fri, 6 Mar 2020 13:58:27 +0800 Subject: [PATCH 3/6] Update chr banking in mapper 217 --- src/boards/addrlatch.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/boards/addrlatch.c b/src/boards/addrlatch.c index e3dba77..8f2f1ba 100644 --- a/src/boards/addrlatch.c +++ b/src/boards/addrlatch.c @@ -377,8 +377,8 @@ void Mapper214_Init(CartInfo *info) { /*------------------ Map 217 ---------------------------*/ static void M217Sync(void) { - setprg32(0x8000, (latche >> 2) & 3); - setchr8(latche & 7); + setprg32(0x8000, (latche >> 2) & 0x03); + setchr8(latche & 0x0F); } void Mapper217_Init(CartInfo *info) { From b00b8031fcb27ec99fa7d69287ecacd8ea19a224 Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Fri, 6 Mar 2020 14:13:36 +0800 Subject: [PATCH 4/6] Fix mirroring on KS7030 board --- src/boards/KS7030.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/boards/KS7030.c b/src/boards/KS7030.c index fd758a5..c6de258 100644 --- a/src/boards/KS7030.c +++ b/src/boards/KS7030.c @@ -25,6 +25,17 @@ * */ +/* 2020-3-6 - update mirroring (negativeExponent) +/* PRG-ROM Bank Select #1/Mirroring Select ($8000-$8FFF, write) + * A~FEDC BA98 7654 3210 + * ------------------- + * 1000 .... .... MBBB + * |+++- Select 4 KiB PRG-ROM bank at CPU $7000-$7FFF + * +---- Select nametable mirroring type + * 0: Vertical + * 1: Horizontal + */ + #include "mapinc.h" #include "../fds_apu.h" @@ -42,8 +53,9 @@ static SFORMAT StateRegs[] = static void Sync(void) { setchr8(0); setprg32(0x8000, ~0); - setprg4(0xb800, reg0); + setprg4(0xb800, reg0 & 0x07); setprg4(0xc800, 8 + reg1); + setmirror(((reg0 >> 3) & 1) ^ 1); } /* 6000 - 6BFF - RAM @@ -99,12 +111,12 @@ static DECLFR(UNLKS7030RamRead1) { } static DECLFW(UNLKS7030Write0) { - reg0 = A & 7; + reg0 = A & 0xF; Sync(); } static DECLFW(UNLKS7030Write1) { - reg1 = A & 15; + reg1 = A & 0xF; Sync(); } From 6a805ea424b204ccd7e3aac656591132fd8994c9 Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Fri, 6 Mar 2020 20:07:15 +0800 Subject: [PATCH 5/6] mapper201: Add support for 21-in-1 (CF-043) (2006-V) (Unl) [p1] --- src/boards/addrlatch.c | 11 +++++++++-- src/ines-correct.h | 3 ++- src/ines.c | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/boards/addrlatch.c b/src/boards/addrlatch.c index 8f2f1ba..b61249a 100644 --- a/src/boards/addrlatch.c +++ b/src/boards/addrlatch.c @@ -274,18 +274,25 @@ void Mapper200_Init(CartInfo *info) { } /*------------------ Map 201 ---------------------------*/ - +/* 2020-3-6 - Support for 21-in-1 (CF-043) (2006-V) (Unl) [p1].nes which has mixed mirroring + * found at the time labeled as submapper 15 (negativeExponent) + * 0x05658DED 128K PRG, 32K CHR */ +static uint32 submapper = 0; static void M201Sync(void) { - if (latche & 8) { + if (latche & 8 || submapper == 15) { setprg32(0x8000, latche & 3); setchr8(latche & 3); } else { setprg32(0x8000, 0); setchr8(0); } + if (submapper == 15) + setmirror(((latche & 0x07) == 0x07) ? MI_V : MI_H); } void Mapper201_Init(CartInfo *info) { + if (info->CRC32 == 0x05658DED) + submapper = 15; Latch_Init(info, M201Sync, NULL, 0xFFFF, 0x8000, 0xFFFF, 0); } diff --git a/src/ines-correct.h b/src/ines-correct.h index 4a54218..3d9f059 100644 --- a/src/ines-correct.h +++ b/src/ines-correct.h @@ -294,7 +294,8 @@ {0xd871d3e6, 199, -1}, /* Dragon Ball Z 2 - Gekishin Freeza! (C) */ {0xed481b7c, 199, -1}, /* Dragon Ball Z Gaiden - Saiya Jin Zetsumetsu Keikaku (C) */ {0x44c20420, 199, -1}, /* San Guo Zhi 2 (C) */ - {0x4e1c1e3c, 206, 0}, /* Karnov */ + {0x44c20420, 199, -1}, /* San Guo Zhi 2 (C) */ + {0x05658DED, 201, -1}, /* 21-in-1 (CF-043) (2006-V) (Unl) [p1].nes, submapper 15 */ {0x276237b3, 206, 0}, /* Karnov */ {0xa5e6baf9, 206, 1}, /* Dragon Slayer 4 - Drasle Family (Japan) */ {0x4f2f1846, 206, 1}, /* Famista '89 - Kaimaku Han!! (J) */ diff --git a/src/ines.c b/src/ines.c index f0e2a8b..1d7f6dd 100644 --- a/src/ines.c +++ b/src/ines.c @@ -596,7 +596,7 @@ static BMAPPINGLocal bmap[] = { {(uint8_t*)"TW MMC3+VRAM Rev. E", 198, Mapper198_Init}, {(uint8_t*)"", 199, Mapper199_Init}, {(uint8_t*)"", 200, Mapper200_Init}, - {(uint8_t*)"", 201, Mapper201_Init}, + {(uint8_t*)"21-in-1", 201, Mapper201_Init}, {(uint8_t*)"", 202, Mapper202_Init}, {(uint8_t*)"", 203, Mapper203_Init}, {(uint8_t*)"", 204, Mapper204_Init}, From a69354c1c24dc7ff50c6c9d83c53b96d59f334db Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Sat, 7 Mar 2020 01:48:36 +0800 Subject: [PATCH 6/6] Add mapper 369 (BMC-N49C-300) --- src/boards/369.c | 153 +++++++++++++++++++++++++++++++++++++++++++++ src/ines-correct.h | 2 + src/ines.c | 1 + src/ines.h | 1 + src/unif.c | 1 + 5 files changed, 158 insertions(+) create mode 100644 src/boards/369.c diff --git a/src/boards/369.c b/src/boards/369.c new file mode 100644 index 0000000..559f539 --- /dev/null +++ b/src/boards/369.c @@ -0,0 +1,153 @@ +/* FCEUmm - NES/Famicom Emulator + * + * Copyright notice for this file: + * Copyright (C) 2020 negativeExponent + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/* Mapper 369 (BMC-N49C-300) - Super Mario Bros. Party multicart */ + +#include "mapinc.h" +#include "mmc3.h" + +static uint8 M40IRQa; +static uint16 M40IRQCount; + +static void M369PW(uint32 A, uint8 V) { + switch (EXPREGS[0]) { + case 0x00: + setprg32(0x8000, 0); + break; + case 0x01: + setprg32(0x8000, 1); + break; + case 0x13: + setprg8(0x6000, 0x0E); + setprg8(0x8000, 0x0C); + setprg8(0xa000, 0x0D); + setprg8(0xc000, EXPREGS[1] | 0x08); + setprg8(0xe000, 0x0F); + break; + case 0x37: + setprg8r(0x10, 0x6000, 0); + setprg8(A, (V & 0x0F) | 0x10); + break; + case 0xFF: + setprg8r(0x10, 0x6000, 0); + setprg8(A, (V & 0x1F) | 0x20); + break; + } +} + +static void M369CW(uint32 A, uint8 V) { + switch (EXPREGS[0]) { + case 0x00: + setchr8(0); + break; + case 0x01: + setchr8(1); + break; + case 0x13: + setprg8(0xE000, 0xF); + setchr8(3); + break; + case 0x37: + setchr1(A, (V & 0x7F) | 0x80); + break; + case 0xFF: + setchr1(A, V | 0x100); + break; + } +} + +static DECLFW(M369WriteCMD) { + EXPREGS[0] = V; + FixMMC3PRG(MMC3_cmd); + FixMMC3CHR(MMC3_cmd); +} + +static DECLFW(M369Write) { + if (EXPREGS[0] == 0x13) { + switch (A & 0xE000) { + case 0x8000: + M40IRQa = 0; + M40IRQCount = 0; + X6502_IRQEnd(FCEU_IQEXT); + break; + case 0xA000: + M40IRQa = 1; + break; + case 0xE000: + EXPREGS[1] = V & 7; + FixMMC3PRG(MMC3_cmd); + FixMMC3CHR(MMC3_cmd); + break; + } + } else { + if (A < 0xC000) { + MMC3_CMDWrite(A, V); + FixMMC3PRG(MMC3_cmd); + FixMMC3CHR(MMC3_cmd); + } else + MMC3_IRQWrite(A, V); + } +} + +static void M369Power(void) { + EXPREGS[0] = 0x00; + EXPREGS[1] = 0x00; + M40IRQa = 0x00; + M40IRQCount = 0x00; + GenMMC3Power(); + SetWriteHandler(0x4120, 0x4120, M369WriteCMD); + SetWriteHandler(0x8000, 0xFFFF, M369Write); +} + +static void M369Reset(void) { + EXPREGS[0] = 0x00; + EXPREGS[1] = 0x00; + M40IRQa = 0x00; + M40IRQCount = 0x00; + MMC3RegReset(); +} + +static void FP_FASTAPASS(1) M40IRQHook(int a) { + if (EXPREGS[0] == 0x13) + { + if (M40IRQa) + { + if (M40IRQCount < 4096) + M40IRQCount += a; + else + { + M40IRQa = 0; + X6502_IRQBegin(FCEU_IQEXT); + } + } + } +} + +void Mapper369_Init(CartInfo *info) { + GenMMC3_Init(info, 512, 384, 8, 0); + pwrap = M369PW; + cwrap = M369CW; + MapIRQHook = M40IRQHook; + info->Power = M369Power; + info->Reset = M369Reset; + AddExState(EXPREGS, 4, 0, "EXPR"); + AddExState(&M40IRQa, 1, 0, "M2a"); + AddExState(&M40IRQCount, 2 | FCEUSTATE_RLSB, 0, "M2CN"); +} diff --git a/src/ines-correct.h b/src/ines-correct.h index 3d9f059..9abc255 100644 --- a/src/ines-correct.h +++ b/src/ines-correct.h @@ -390,6 +390,8 @@ {0x5aa23a15, 361, 0}, /* 4-in-1 (OK-411)[p1][!] */ {0xf6b9d088, 366, 0}, /* 4-in-1 (K-3131GS, GN-45) [p1][!] */ {0x503566b2, 366, 0}, /* 4-in-1 (K-3131SS, GN-45) [p1][!] */ + {0xDB2D2D88, 369, -1}, /* Super Mario Bros. Party.nes */ + /* ines mappers that uses unif boards */ diff --git a/src/ines.c b/src/ines.c index 1d7f6dd..20f73a1 100644 --- a/src/ines.c +++ b/src/ines.c @@ -753,6 +753,7 @@ static BMAPPINGLocal bmap[] = { {(uint8_t*)"G-146", 349, BMCG146_Init }, {(uint8_t*)"891227", 350, BMC891227_Init }, {(uint8_t*)"3D-BLOCK", 355, UNL3DBlock_Init }, + {(uint8_t*)"Super Mario Bros. Party (N49C-300)", 369, Mapper369_Init }, {(uint8_t*)"NC7000M", 391, NC7000M_Init }, {(uint8_t*)"831019C J-2282", 402, J2282_Init }, {(uint8_t*)"SA-9602B", 513, SA9602B_Init }, diff --git a/src/ines.h b/src/ines.h index cd21141..5637c7f 100644 --- a/src/ines.h +++ b/src/ines.h @@ -257,6 +257,7 @@ void Mapper356_Init(CartInfo *); void Mapper357_Init(CartInfo *); void Mapper359_Init(CartInfo *); void Mapper360_Init(CartInfo *); +void Mapper369_Init(CartInfo *); void Mapper372_Init(CartInfo *); void Mapper374_Init(CartInfo *); void Mapper382_Init(CartInfo *); diff --git a/src/unif.c b/src/unif.c index fae0a74..af48531 100644 --- a/src/unif.c +++ b/src/unif.c @@ -608,6 +608,7 @@ static BMAPPING bmap[] = { { "WX-KB4K", 134, Bs5652_Init, 0 }, { "SB-5013", 359, Mapper359_Init, 0 }, { "82112C", 540, Mapper540_Init, 0 }, + { "N49C-300", 369, Mapper369_Init }, #ifdef COPYFAMI { "COPYFAMI_MMC3", NO_INES, MapperCopyFamiMMC3_Init, 0 },