From bc8767ef2616510e4b296ba7d84fa25bb1c41a84 Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Sun, 6 Feb 2022 18:05:36 +0800 Subject: [PATCH] Add mapper 396 --- src/boards/396.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++++ src/ines.c | 1 + src/ines.h | 1 + src/unif.c | 1 + 4 files changed, 76 insertions(+) create mode 100644 src/boards/396.c diff --git a/src/boards/396.c b/src/boards/396.c new file mode 100644 index 0000000..5b58694 --- /dev/null +++ b/src/boards/396.c @@ -0,0 +1,73 @@ +/* FCEUmm - NES/Famicom Emulator + * + * Copyright notice for this file: + * Copyright (C) 2022 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 + * + * NES 2.0 Mapper 396 - BMC-830752C + * 1995 Super 8-in-1 (JY-050 rev0) + * Super 8-in-1 Gold Card Series (JY-085) + * Super 8-in-1 Gold Card Series (JY-086) + * 2-in-1 (GN-51) + */ + +#include "mapinc.h" + +static uint8 reg[2]; + +static void Sync (void) { + setprg16(0x8000, reg[1] << 3 | reg[0] & 7); + setprg16(0xC000, reg[1] << 3 | 7); + setchr8(0); + setmirror(((reg[0] >> 6) & 1) ^ 1); +} + +static DECLFW(M396WriteInnerBank) { + reg[0] = V; + Sync(); +} + +static DECLFW(M396WriteOuterBank) { + reg[1] = V; + Sync(); +} + +static void M396Reset(void) { + reg[0] = 0x00; + reg[1] = 0x00; + Sync(); +} + +static void StateRestore(void) { + Sync(); +} + +static void M396Power(void) { + reg[0] = 0x00; + reg[1] = 0x00; + Sync(); + SetReadHandler(0x8000, 0xFFFF, CartBR); + SetWriteHandler(0x8000, 0x9FFF, M396WriteInnerBank); + SetWriteHandler(0xA000, 0xBFFF, M396WriteOuterBank); + SetWriteHandler(0xC000, 0xFFFF, M396WriteInnerBank); +} + +void Mapper396_Init(CartInfo *info) { + info->Power = M396Power; + info->Reset = M396Reset; + GameStateRestore = StateRestore; + AddExState(reg, 2, 0, "REGS"); +} diff --git a/src/ines.c b/src/ines.c index e75a052..4d89bab 100644 --- a/src/ines.c +++ b/src/ines.c @@ -792,6 +792,7 @@ INES_BOARD_BEGIN() INES_BOARD( "YY850735C", 387, Mapper387_Init ) INES_BOARD( "YY850835C", 388, Mapper388_Init ) INES_BOARD( "BS-110", 391, Mapper391_Init ) + INES_BOARD( "YY850437C", 396, Mapper396_Init ) INES_BOARD( "YY850439C", 397, Mapper397_Init ) INES_BOARD( "831019C J-2282", 402, J2282_Init ) INES_BOARD( "SC871115C", 421, Mapper421_Init ) diff --git a/src/ines.h b/src/ines.h index 0e95552..5874029 100644 --- a/src/ines.h +++ b/src/ines.h @@ -284,6 +284,7 @@ void Mapper389_Init(CartInfo *); void Mapper390_Init(CartInfo *); void Mapper391_Init(CartInfo *); void Mapper395_Init(CartInfo *); +void Mapper396_Init(CartInfo *); void Mapper397_Init(CartInfo *); void Mapper401_Init(CartInfo *); void Mapper403_Init(CartInfo *); diff --git a/src/unif.c b/src/unif.c index c6dc25c..5ce0560 100644 --- a/src/unif.c +++ b/src/unif.c @@ -616,6 +616,7 @@ static BMAPPING bmap[] = { { "SB-5013", 359, Mapper359_Init, 0 }, { "82112C", 540, Mapper540_Init, 0 }, { "N49C-300", 369, Mapper369_Init, 0 }, + { "830752C", 396, Mapper396_Init, 0 }, { "BS-400R", 422, Mapper422_Init, 0 }, { "BS-4040R", 422, Mapper422_Init, 0 },