From 1e15064ec5ee3ed462593eb77daa203478e1ce45 Mon Sep 17 00:00:00 2001 From: NewRisingSun <8vytz1+dhp372pv94ebg@sharklasers.com> Date: Sun, 21 Sep 2025 22:02:30 +0200 Subject: [PATCH] Add mappers 597 and 598. --- src/boards/597.c | 75 ++++++++++++++++++++++++++++++++++++++++++++++++ src/boards/598.c | 63 ++++++++++++++++++++++++++++++++++++++++ src/ines.c | 2 ++ src/ines.h | 2 ++ 4 files changed, 142 insertions(+) create mode 100644 src/boards/597.c create mode 100644 src/boards/598.c diff --git a/src/boards/597.c b/src/boards/597.c new file mode 100644 index 0000000..5f2846a --- /dev/null +++ b/src/boards/597.c @@ -0,0 +1,75 @@ +/* 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 + * + * + */ + +#include "mapinc.h" +#include "asic_mmc3.h" + +static uint8 reg; +static uint8 pad; + +static DECLFR (readPad) { + return CartBR(A &~0xF | pad &0xF); +} + +static void sync () { + int prgAND = 0x0F; + int chrAND = reg &0x01? 0xFF: 0x7F; + int prgOR = reg <<4; + int chrOR = (reg &0x02? 0x080: 0x000) | (reg &0x01 && ~reg &0x02? 0x100: 0x000); + MMC3_syncPRG(prgAND, prgOR &~prgAND); + MMC3_syncCHR(chrAND, chrOR &~chrAND); + MMC3_syncMirror(); + SetReadHandler(0x8000, 0xFFFF, reg &0x20? readPad: CartBR); +} + +static int getPRGBank (uint8 bank) { + if (reg &0x04) { + int mask = reg &0x10? 1: 3; + return MMC3_getPRGBank(0) &~mask | bank &mask; + } else + return MMC3_getPRGBank(bank); +} + +static DECLFW (writeReg) { + reg = A &0xFF; + sync(); +} + +static void reset () { + reg = 0; + pad++; + MMC3_clear(); +} + +static void power () { + reg = 0; + pad = 0; + MMC3_power(); +} + +void Mapper597_Init (CartInfo *info) { + MMC3_init(info, sync, MMC3_TYPE_SHARP, getPRGBank, NULL, NULL, writeReg); + info->Power = power; + info->Reset = reset; + AddExState(®, 1, 0, "EXPR"); + AddExState(&pad, 1, 0, "DIPS"); +} diff --git a/src/boards/598.c b/src/boards/598.c new file mode 100644 index 0000000..63c0274 --- /dev/null +++ b/src/boards/598.c @@ -0,0 +1,63 @@ +/* FCE Ultra - NES/Famicom Emulator + * + * Copyright notice for this file: + * Copyright (C) 2025 NewRisingSun + * + * 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 + */ + +#include "mapinc.h" + +static uint8 reg[4]; + +static void sync () { + int prg = reg[3] <<3 | reg[1] &0x07; + if (reg[3] &0x08) + setprg32(0x8000, prg >>1); + else { + setprg16(0x8000, prg); + setprg16(0xC000, prg |7); + } + setchr4(0x0000, reg[3] <<5 | reg[1] >>3 &0x1F); + setchr4(0x1000, reg[3] <<5 | reg[2] >>3 &0x1F); + setmirror(reg[3] &0x04? MI_H: MI_V); +} + +static DECLFW (writeReg) { + reg[A >>13 &3] = V; + sync(); +} + +static void reset () { + reg[0] = reg[1] = reg[2] = reg[3] = 0; + sync(); +} + +static void power () { + SetReadHandler(0x6000, 0xFFFF, CartBR); + SetWriteHandler(0x8000, 0xFFFF, writeReg); + reset(); +} + +static void stateRestore (int version) { + sync(); +} + +void Mapper598_Init (CartInfo *info) { + info->Power = power; + info->Reset = reset; + GameStateRestore = stateRestore; + AddExState(reg, 4, 0, "REGS"); +} diff --git a/src/ines.c b/src/ines.c index f8ef459..a99c4c8 100644 --- a/src/ines.c +++ b/src/ines.c @@ -1018,6 +1018,8 @@ INES_BOARD_BEGIN() INES_BOARD( "Rinco FSG2", 594, Mapper594_Init ) INES_BOARD( "4MROM-512", 595, Mapper595_Init ) INES_BOARD( "FC-49", 596, Mapper596_Init ) + INES_BOARD( "GN-27", 597, Mapper597_Init ) + INES_BOARD( "New Star 21-in-1", 598, Mapper598_Init ) INES_BOARD_END() static uint32 iNES_get_mapper_id(void) diff --git a/src/ines.h b/src/ines.h index d9f9c62..83f3ce2 100644 --- a/src/ines.h +++ b/src/ines.h @@ -487,6 +487,8 @@ void Mapper592_Init(CartInfo *); void Mapper594_Init(CartInfo *); void Mapper595_Init(CartInfo *); void Mapper596_Init(CartInfo *); +void Mapper597_Init(CartInfo *); +void Mapper598_Init(CartInfo *); void FFE_Init(CartInfo *);