diff --git a/src/boards/483.c b/src/boards/483.c new file mode 100644 index 0000000..d033363 --- /dev/null +++ b/src/boards/483.c @@ -0,0 +1,79 @@ +/* FCEUmm - NES/Famicom Emulator + * + * Copyright notice for this file: + * Copyright (C) 2020 + * + * 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 + * + * + */ + +/* 3927 PCB, reset-based MMC1/CNROM multicart. The common dump with mapper number 3927 has an unrealistic bank order. */ + +#include "mapinc.h" +#include "asic_latch.h" +#include "asic_mmc1.h" + +static uint8 game; + +static void sync_SLROM () { + MMC1_syncPRG(0x07, game <<3); + MMC1_syncCHR(0x1F, game <<5); + MMC1_syncMirror(); +} + +static void sync_CNROM () { + setprg32(0x8000, 0x0C +game -3); + setchr8(0x30 | (game -3) <<2 | Latch_data &0x03); + setmirror(MI_V); +} + +static void sync_SEROM () { + setprg32(0x8000, 0x0F); + MMC1_syncCHR(0x07, 0x78); + MMC1_syncMirror(); +} + +static void applyMode (uint8 clear) { + if (game <= 2) + MMC1_activate(clear, sync_SLROM, MMC1_TYPE_MMC1B, NULL, NULL, NULL, NULL); + else + if (game <= 5) + Latch_activate(clear, sync_CNROM, 0x8000, 0xFFFF, NULL); + else + MMC1_activate(clear, sync_SEROM, MMC1_TYPE_MMC1B, NULL, NULL, NULL, NULL); +} + +static void reset () { + if (++game >=7) game = 0; + applyMode(1); +} + +static void power () { + game = 0; + applyMode(1); +} + +static void stateRestore(int version) { + applyMode(0); +} +void Mapper483_Init (CartInfo *info) { + AddExState(&game, 1, 0, "GAME"); + Latch_addExState(); + MMC1_addExState(); + info->Power = power; + info->Reset = reset; + GameStateRestore = stateRestore; +} diff --git a/src/ines.c b/src/ines.c index 5f86258..14cb968 100644 --- a/src/ines.c +++ b/src/ines.c @@ -912,6 +912,7 @@ INES_BOARD_BEGIN() INES_BOARD( "480", 480, Mapper480_Init ) INES_BOARD( "045N", 481, Mapper481_Init ) INES_BOARD( "K-1079", 482, Mapper482_Init ) + INES_BOARD( "3927", 483, Mapper483_Init ) INES_BOARD( "ESTIQUE", 484, Mapper484_Init ) INES_BOARD( "0359", 485, Mapper485_Init ) INES_BOARD( "KS7009", 486, Mapper486_Init ) diff --git a/src/ines.h b/src/ines.h index 36f1d25..e179c7f 100644 --- a/src/ines.h +++ b/src/ines.h @@ -393,6 +393,7 @@ void Mapper478_Init(CartInfo *); void Mapper480_Init(CartInfo *); void Mapper481_Init(CartInfo *); void Mapper482_Init(CartInfo *); +void Mapper483_Init(CartInfo *); void Mapper484_Init(CartInfo *); void Mapper485_Init(CartInfo *); void Mapper486_Init(CartInfo *);