diff --git a/src/boards/280.c b/src/boards/280.c new file mode 100644 index 0000000..07deac1 --- /dev/null +++ b/src/boards/280.c @@ -0,0 +1,83 @@ +/* FCEUmm - 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 uint16 latchAddr; +static uint8 latchData; +static uint8 mode; + +static SFORMAT StateRegs[] = { + { &latchAddr, 2 | FCEUSTATE_RLSB, "LATC" }, + { &latchData, 1, "DATA" }, + { &mode, 1, "MODE" }, + { 0 } +}; + +static void Sync(void) { + if (mode &1) { + setprg16(0x8000, 0x20 | latchData &0x07); + setprg16(0xC000, 0x27); + } else { + if (latchAddr &0x01) + setprg32(0x8000, latchAddr >>3 &0x0F); + else { + setprg16(0x8000, latchAddr >>2 &0x1F); + setprg16(0xC000, latchAddr >>2 &0x1F); + } + if (~latchAddr &0x80) setprg16(0xC000, 0); + } + SetupCartCHRMapping(0, CHRptr[0], 0x2000, ~mode &0x01 && latchAddr &0x80? 0: 1); + setchr8(0); + setmirror(latchAddr &0x02? MI_H: MI_V); +} + +static DECLFW(M280Write) { + latchAddr =A; + latchData =V; + Sync(); +} + +static void M280Reset(void) { + mode ^=1; + latchAddr = 0; + latchData = 0; + Sync(); +} + +static void M280Power(void) { + mode =0; + latchAddr = 0; + latchData = 0; + Sync(); + SetReadHandler(0x8000, 0xFFFF, CartBR); + SetWriteHandler(0x8000, 0xFFFF, M280Write); +} + +static void StateRestore(int version) { + Sync(); +} + +void Mapper280_Init(CartInfo *info) { + info->Power = M280Power; + info->Reset = M280Reset; + GameStateRestore = StateRestore; + AddExState(&StateRegs, ~0, 0, 0); +} diff --git a/src/ines.c b/src/ines.c index cb8596b..432254f 100644 --- a/src/ines.c +++ b/src/ines.c @@ -698,6 +698,7 @@ INES_BOARD_BEGIN() INES_BOARD( "Akumajō Special: Boku Dracula-kun", 272, Mapper272_Init ) INES_BOARD( "80013-B", 274, BMC80013B_Init ) INES_BOARD( "", 277, Mapper277_Init ) + INES_BOARD( "K-3017", 280, Mapper280_Init ) INES_BOARD( "YY860417C", 281, Mapper281_Init ) INES_BOARD( "860224C", 282, Mapper282_Init ) INES_BOARD( "GS-2004/GS-2013", 283, Mapper283_Init ) diff --git a/src/ines.h b/src/ines.h index c773541..8121042 100644 --- a/src/ines.h +++ b/src/ines.h @@ -253,6 +253,7 @@ void GN45_Init(CartInfo *info); /* m361, m366 */ void Mapper270_Init(CartInfo *); void Mapper272_Init(CartInfo *); void Mapper277_Init(CartInfo *); +void Mapper280_Init(CartInfo *); void Mapper281_Init(CartInfo *); void Mapper282_Init(CartInfo *); void Mapper283_Init(CartInfo *);