From 03c42f32b30374f56f5c2b0a6eaea3557cb69c7d Mon Sep 17 00:00:00 2001 From: negativeExponent <54053706+negativeExponent@users.noreply.github.com> Date: Mon, 24 Jan 2022 22:53:53 +0800 Subject: [PATCH] update (#483) * Fix missing GameStateRestore * Add mapper 403 Co-authored-by: negativeExponent --- src/boards/403.c | 81 +++++++++++++++++++++++++++++++++++++++++++++ src/boards/434.c | 5 +++ src/boards/437.c | 5 +++ src/boards/438.c | 5 +++ src/boards/KS7057.c | 5 +++ src/boards/le05.c | 5 +++ src/ines.c | 1 + src/ines.h | 1 + 8 files changed, 108 insertions(+) create mode 100644 src/boards/403.c diff --git a/src/boards/403.c b/src/boards/403.c new file mode 100644 index 0000000..aa1ad46 --- /dev/null +++ b/src/boards/403.c @@ -0,0 +1,81 @@ +/* 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 403 denotes the 89433 circuit board with up to 1 MiB PRG-ROM and 32 KiB of CHR-RAM, bankable with 8 KiB granularity. + * + * Tetris Family - 玩家 19-in-1 智瑟實典 (NO-1683) + * Sachen Superpack (versions A-C) + */ + +#include "mapinc.h" + +static uint8 reg[3]; + +static void Sync(void) { + uint8 prg = reg[0]; + uint8 chr = reg[1]; + uint8 mode = reg[2]; + + /* NROM-128 */ + if (mode & 1) { + setprg16(0x8000, prg >> 1); + setprg16(0xC000, prg >> 1); + /* NROM-256 */ + } else + setprg32(0x8000, prg >> 2); + setchr8(chr); + setmirror(((mode >> 4) & 1) ^ 1); +} + +static DECLFW(M403Write4) { + reg[A & 3] = V; + Sync(); +} + +static DECLFW(M403Write8) { + if (reg[2] & 4) { + reg[1] = V; + Sync(); + } +} + +static void M403Reset(void) { + reg[0] = reg[1] = reg[2] = 0; + Sync(); +} + +static void M403Power(void) { + reg[0] = reg[1] = reg[2] = 0; + Sync(); + SetReadHandler(0x8000, 0xFFFF, CartBR); + SetWriteHandler(0x4100, 0x4103, M403Write4); + SetWriteHandler(0x8000, 0xFFFF, M403Write8); +} + +static void StateRestore(void) { + Sync(); +} + +void Mapper403_Init(CartInfo *info) { + info->Reset = M403Reset; + info->Power = M403Power; + GameStateRestore = StateRestore; + AddExState(®, 3, 0, "REGS"); +} diff --git a/src/boards/434.c b/src/boards/434.c index f005162..2a6c5a2 100644 --- a/src/boards/434.c +++ b/src/boards/434.c @@ -55,8 +55,13 @@ static void Mapper434_Power(void) { SetWriteHandler(0x8000, 0xFFFF, Mapper434_WriteInnerBank); } +static void StateRestore(void) { + Mapper434_Sync(); +} + void Mapper434_Init(CartInfo *info) { info->Reset = Mapper434_Reset; info->Power = Mapper434_Power; + GameStateRestore = StateRestore; AddExState(&latch, 2, 0, "LATC"); } diff --git a/src/boards/437.c b/src/boards/437.c index d12e294..5541877 100644 --- a/src/boards/437.c +++ b/src/boards/437.c @@ -55,8 +55,13 @@ static void Mapper437_Power(void) { SetWriteHandler(0x8000, 0xFFFF, Mapper437_WriteInnerBank); } +static void StateRestore(void) { + Mapper437_Sync(); +} + void Mapper437_Init(CartInfo *info) { info->Reset = Mapper437_Reset; info->Power = Mapper437_Power; + GameStateRestore = StateRestore; AddExState(&latch, 1, 0, "LATC"); } diff --git a/src/boards/438.c b/src/boards/438.c index 1602644..da5ed83 100644 --- a/src/boards/438.c +++ b/src/boards/438.c @@ -55,8 +55,13 @@ static void Mapper438_Power(void) { SetWriteHandler(0x8000, 0xFFFF, Mapper438_WriteLatch); } +static void StateRestore(void) { + Mapper438_Sync(); +} + void Mapper438_Init(CartInfo *info) { info->Reset = Mapper438_Reset; info->Power = Mapper438_Power; + GameStateRestore = StateRestore; AddExState(&latch, 2, 0, "LATC"); } diff --git a/src/boards/KS7057.c b/src/boards/KS7057.c index 3762138..be32d24 100644 --- a/src/boards/KS7057.c +++ b/src/boards/KS7057.c @@ -85,8 +85,13 @@ static void UNLKS7057Reset(void) { Sync(); } +static void StateRestore(int version) { + Sync(); +} + void UNLKS7057_Init(CartInfo *info) { info->Power = UNLKS7057Power; info->Reset = UNLKS7057Reset; + GameStateRestore = StateRestore; AddExState(&StateRegs, ~0, 0, 0); } diff --git a/src/boards/le05.c b/src/boards/le05.c index 59eab1a..cd2000e 100644 --- a/src/boards/le05.c +++ b/src/boards/le05.c @@ -56,7 +56,12 @@ static void LE05Power(void) { SetWriteHandler(0x8000, 0xFFFF, LE05Write); } +static void StateRestore(int version) { + Sync(); +} + void LE05_Init(CartInfo *info) { info->Power = LE05Power; + GameStateRestore = StateRestore; AddExState(&StateRegs, ~0, 0, 0); } diff --git a/src/ines.c b/src/ines.c index 10a731f..5dc6722 100644 --- a/src/ines.c +++ b/src/ines.c @@ -706,6 +706,7 @@ INES_BOARD_BEGIN() INES_BOARD( "NewStar 12-in-1/7-in-1", 293, Mapper293_Init ) INES_BOARD( "Realtec 8210", 395, Mapper395_Init ) INES_BOARD( "BMC Super 19-in-1 (VIP19)", 401, Mapper401_Init ) + INES_BOARD( "89433", 403, Mapper403_Init ) INES_BOARD( "A88S-1", 411, Mapper411_Init ) INES_BOARD( "BS-400R/BS-4040", 422, Mapper422_Init ) INES_BOARD( "Brilliant Com Cocoma Pack", 516, Mapper516_Init ) diff --git a/src/ines.h b/src/ines.h index 3a500cc..d0f2b0a 100644 --- a/src/ines.h +++ b/src/ines.h @@ -284,6 +284,7 @@ void Mapper391_Init(CartInfo *); void Mapper395_Init(CartInfo *); void Mapper397_Init(CartInfo *); void Mapper401_Init(CartInfo *); +void Mapper403_Init(CartInfo *); void Mapper411_Init(CartInfo *); void Mapper421_Init(CartInfo *); void Mapper422_Init(CartInfo *);