From 344c12301fc661e1fdb752788a589497e7fc334e Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Mon, 26 Oct 2020 09:22:11 +0800 Subject: [PATCH] Add mapper 370 and 395, update mapper 221 Add support for mapper 395 Add support for mapper 370 Update mapper 221 for 2MB bank support --- src/boards/370.c | 96 ++++++++++++++++++++++++++++++++++++++++++++ src/boards/395.c | 67 +++++++++++++++++++++++++++++++ src/boards/n625092.c | 20 ++++----- src/ines.c | 2 + src/ines.h | 2 + 5 files changed, 177 insertions(+), 10 deletions(-) create mode 100644 src/boards/370.c create mode 100644 src/boards/395.c diff --git a/src/boards/370.c b/src/boards/370.c new file mode 100644 index 0000000..25f5887 --- /dev/null +++ b/src/boards/370.c @@ -0,0 +1,96 @@ +/* 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 370 - F600 + * Golden Mario Party II - Around the World (6-in-1 multicart) + */ + +#include "mapinc.h" +#include "mmc3.h" + +static uint8 PPUCHRBus; +static uint8 mirr[8]; + +static void FP_FASTAPASS(1) M370PPU(uint32 A) { + if ((EXPREGS[0] & 7) == 1) { + A &= 0x1FFF; + A >>= 10; + PPUCHRBus = A; + setmirror(MI_0 + mirr[A]); + } +} + +static void M370CW(uint32 A, uint8 V) { + uint8 mask = (EXPREGS[0] & 4) ? 0x7F : 0xFF; + /* FIXME: Mario VII, mask is reversed? */ + if ((EXPREGS[0] & 7) == 6 && V & 0x80) + mask = 0xFF; + mirr[A >> 10] = V >> 7; + setchr1(A, (V & mask) | ((EXPREGS[0] & 7) << 7)); + if (((EXPREGS[0] & 7) == 1) && (PPUCHRBus == (A >> 10))) + setmirror(MI_0 + (V >> 7)); +} + +static void M370PW(uint32 A, uint8 V) { + uint8 mask = EXPREGS[0] & 0x20 ? 0x0F : 0x1F; + setprg8(A, (V & mask) | ((EXPREGS[0] & 0x38) << 1)); +} + +static void M370MW(uint8 V) { + A000B = V; + if ((EXPREGS[0] & 7) != 1) + setmirror((V & 1) ^ 1); +} + +static DECLFR(M370Read) {; + return (EXPREGS[1] << 7); +} + +static DECLFW(M370Write) { + EXPREGS[0] = (A & 0xFF); + FixMMC3PRG(MMC3_cmd); + FixMMC3CHR(MMC3_cmd); +} + +static void M370Reset(void) { + EXPREGS[0] = 0; + EXPREGS[1] ^= 1; + FCEU_printf("solderpad=%02x\n", EXPREGS[1]); + MMC3RegReset(); +} + +static void M370Power(void) { + EXPREGS[0] = 0; + EXPREGS[1] = 1; /* start off with the 6-in-1 menu */ + GenMMC3Power(); + SetReadHandler(0x5000, 0x5FFF, M370Read); + SetWriteHandler(0x5000, 0x5FFF, M370Write); +} + +void Mapper370_Init(CartInfo *info) { + GenMMC3_Init(info, 256, 256, 8, 0); + cwrap = M370CW; + pwrap = M370PW; + mwrap = M370MW; + PPU_hook = M370PPU; + info->Power = M370Power; + info->Reset = M370Reset; + AddExState(EXPREGS, 2, 0, "EXPR"); +} diff --git a/src/boards/395.c b/src/boards/395.c new file mode 100644 index 0000000..6508850 --- /dev/null +++ b/src/boards/395.c @@ -0,0 +1,67 @@ +/* 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 395 - Realtec 8210 + * Super Card 12-in-1 (SPC002) + * Super Card 13-in-1 (SPC003) + * Super Card 14-in-1 (King006) + * Super Card 14-in-1 (King007) + */ + +#include "mapinc.h" +#include "mmc3.h" + +static void M395CW(uint32 A, uint8 V) { + uint8 mask = EXPREGS[1] & 0x40 ? 0x7F : 0xFF; + setchr1(A, (V & mask) | ((EXPREGS[1] & 0x10) << 3) | ((EXPREGS[0] & 0x30) << 4) | ((EXPREGS[1] & 0x20) << 5)); +} + +static void M395PW(uint32 A, uint8 V) { + uint8 mask = EXPREGS[1] & 8 ? 0x0F : 0x1F; + setprg8(A, (V & mask) | ((EXPREGS[0] & 0x30) << 1) | ((EXPREGS[0] & 8) << 4) | ((EXPREGS[1] & 1) << 4)); +} + +static DECLFW(M395Write) { + if (!(EXPREGS[1] & 0x80)) { + EXPREGS[(A >> 4) & 1] = V; + FixMMC3PRG(MMC3_cmd); + FixMMC3CHR(MMC3_cmd); + } +} + +static void M395Reset(void) { + EXPREGS[0] = EXPREGS[1] = 0; + MMC3RegReset(); +} + +static void M395Power(void) { + EXPREGS[0] = EXPREGS[1] = 0; + GenMMC3Power(); + SetWriteHandler(0x6000, 0x7FFF, M395Write); +} + +void Mapper395_Init(CartInfo *info) { + GenMMC3_Init(info, 256, 256, 0, 0); + cwrap = M395CW; + pwrap = M395PW; + info->Power = M395Power; + info->Reset = M395Reset; + AddExState(EXPREGS, 2, 0, "EXPR"); +} diff --git a/src/boards/n625092.c b/src/boards/n625092.c index 1f134c0..800d986 100644 --- a/src/boards/n625092.c +++ b/src/boards/n625092.c @@ -18,18 +18,17 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * 700in1 and 400in1 carts - * + * 1000-in-1 */ - #include "mapinc.h" static uint16 cmd, bank; static SFORMAT StateRegs[] = { - { &cmd, 2, "CMD" }, - { &bank, 2, "BANK" }, + { &cmd, 2 | FCEUSTATE_RLSB, "CMD" }, + { &bank, 2 | FCEUSTATE_RLSB, "BANK" }, { 0 } }; @@ -38,15 +37,15 @@ static void Sync(void) { setchr8(0); if (cmd & 2) { if (cmd & 0x100) { - setprg16(0x8000, ((cmd & 0xfc) >> 2) | bank); - setprg16(0xC000, ((cmd & 0xfc) >> 2) | 7); + setprg16(0x8000, ((cmd & 0x200) >> 3) | ((cmd & 0xfc) >> 2) | bank); + setprg16(0xC000, ((cmd & 0x200) >> 3) | ((cmd & 0xfc) >> 2) | 7); } else { - setprg16(0x8000, ((cmd & 0xfc) >> 2) | (bank & 6)); - setprg16(0xC000, ((cmd & 0xfc) >> 2) | ((bank & 6) | 1)); + setprg16(0x8000, ((cmd & 0x200) >> 3) | ((cmd & 0xfc) >> 2) | (bank & 6)); + setprg16(0xC000, ((cmd & 0x200) >> 3) | ((cmd & 0xfc) >> 2) | ((bank & 6) | 1)); } } else { - setprg16(0x8000, ((cmd & 0xfc) >> 2) | bank); - setprg16(0xC000, ((cmd & 0xfc) >> 2) | bank); + setprg16(0x8000, ((cmd & 0x200) >> 3) | ((cmd & 0xfc) >> 2) | bank); + setprg16(0xC000, ((cmd & 0x200) >> 3) | ((cmd & 0xfc) >> 2) | bank); } } @@ -81,6 +80,7 @@ static void UNLN625092Reset(void) { bank = 0; ass++; FCEU_printf("%04x\n", ass); + Sync(); } static void StateRestore(int version) { diff --git a/src/ines.c b/src/ines.c index ab839b7..93c3761 100644 --- a/src/ines.c +++ b/src/ines.c @@ -694,6 +694,7 @@ INES_BOARD_BEGIN() INES_BOARD( "Bitcorp 31-in-1", 360, Mapper360_Init ) INES_BOARD( "OK-411", 361, GN45_Init ) /* OK-411 is emulated together with GN-45 */ INES_BOARD( "GN-45", 366, GN45_Init ) + INES_BOARD( "Golden Mario Party II - Around the World 6-in-1", 370, Mapper370_Init ) INES_BOARD( "MMC3 PIRATE SFC-12", 372, Mapper372_Init ) INES_BOARD( "95/96 Super HiK 4-in-1", 374, Mapper374_Init ) INES_BOARD( "42 to 80,000 (970630C)", 380, Mapper380_Init ) @@ -701,6 +702,7 @@ INES_BOARD_BEGIN() INES_BOARD( "830928C", 382, Mapper382_Init ) INES_BOARD( "Caltron 9-in-1", 389, Mapper389_Init ) INES_BOARD( "Realtec 8031", 390, Mapper390_Init ) + INES_BOARD( "Realtec 8210", 395, Mapper395_Init ) INES_BOARD( "A88S-1", 411, Mapper411_Init ) INES_BOARD( "Brilliant Com Cocoma Pack", 516, Mapper516_Init ) INES_BOARD( "Sachen 3014", 533, Mapper533_Init ) diff --git a/src/ines.h b/src/ines.h index bc119f2..43085e4 100644 --- a/src/ines.h +++ b/src/ines.h @@ -259,6 +259,7 @@ void Mapper357_Init(CartInfo *); void Mapper359_Init(CartInfo *); void Mapper360_Init(CartInfo *); void Mapper369_Init(CartInfo *); +void Mapper370_Init(CartInfo *); void Mapper372_Init(CartInfo *); void Mapper374_Init(CartInfo *); void Mapper380_Init(CartInfo *); @@ -266,6 +267,7 @@ void Mapper381_Init(CartInfo *); void Mapper382_Init(CartInfo *); void Mapper389_Init(CartInfo *); void Mapper390_Init(CartInfo *); +void Mapper395_Init(CartInfo *); void Mapper411_Init(CartInfo *); void Mapper516_Init(CartInfo *); void Mapper533_Init(CartInfo *);