diff --git a/src/boards/447.c b/src/boards/447.c new file mode 100644 index 0000000..0af097e --- /dev/null +++ b/src/boards/447.c @@ -0,0 +1,82 @@ +/* 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" +#include "vrc2and4.h" + +static uint8 reg; +static uint8 dip; + +static SFORMAT Mapper447_stateRegs[] ={ + { ®, 1, "EXP0" }, + { ®, 1, "DIPS" }, + { 0 } +}; + +static void sync () { + VRC24_syncPRG(0x0F, reg <<4); + VRC24_syncCHR(0x7F, reg <<7); + VRC24_syncMirror(); + VRC24_syncWRAM(0); +} + +static int Mapper447_getPRGBank(int bank) { + if (reg &4) { + if (~reg &2) + return VRC24_getPRGBank(bank &1) &~2 | bank &2; + else + return VRC24_getPRGBank(bank &1); + } else + return VRC24_getPRGBank(bank); +} + +DECLFR(Mapper447_readPRG) { + return CartBR(reg &8? (A &~3 | dip &3): A); +} + +DECLFW(Mapper447_writeReg) { + if (VRC24_misc &1 && ~reg &1) { + reg =A &0xFF; + VRC24_Sync(); + } + CartBW(A, V); +} + +void Mapper447_power(void) { + reg =0; + dip =0; + VRC24_power(); + SetReadHandler(0x8000, 0xFFFF, Mapper447_readPRG); +} + +void Mapper447_reset(void) { + reg =0; + dip++; + VRC24_Sync(); +} + +void Mapper447_Init (CartInfo *info) { + VRC24_init(info, sync, 0x04, 0x08, 1, 0, 2); + VRC24_WRAMWrite =Mapper447_writeReg; + VRC24_GetPRGBank =Mapper447_getPRGBank; + info->Power =Mapper447_power; + info->Reset =Mapper447_reset; + AddExState(Mapper447_stateRegs, ~0, 0, 0); +} diff --git a/src/ines.c b/src/ines.c index 97f5e85..791d68b 100644 --- a/src/ines.c +++ b/src/ines.c @@ -834,6 +834,7 @@ INES_BOARD_BEGIN() INES_BOARD( "NC-3000M", 443, Mapper443_Init ) INES_BOARD( "NC-7000M/NC-8000M", 444, Mapper444_Init ) INES_BOARD( "DG574B", 445, Mapper445_Init ) + INES_BOARD( "KL-06", 447, Mapper447_Init ) INES_BOARD( "830768C", 448, Mapper448_Init ) INES_BOARD( "22-in-1 King Series", 449, Mapper449_Init ) INES_BOARD( "DS-9-27", 452, Mapper452_Init ) diff --git a/src/ines.h b/src/ines.h index e4b361f..314b476 100644 --- a/src/ines.h +++ b/src/ines.h @@ -345,6 +345,7 @@ void Mapper441_Init(CartInfo *); void Mapper443_Init(CartInfo *); void Mapper444_Init(CartInfo *); void Mapper445_Init(CartInfo *); +void Mapper447_Init(CartInfo *); void Mapper448_Init(CartInfo *); void Mapper449_Init(CartInfo *); void Mapper452_Init(CartInfo *);