diff --git a/src/boards/554.c b/src/boards/554.c new file mode 100644 index 0000000..bbb4796 --- /dev/null +++ b/src/boards/554.c @@ -0,0 +1,77 @@ +/* FCEUmm - NES/Famicom Emulator + * + * Copyright notice for this file: + * Copyright (C) 2020 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 + */ + +/* Mapper 554 - Kaiser KS-7010 + * used for one of several cartridge conversions of the FDS version of + * 悪魔城 Dracula, the Japanese version of Castlevania + */ + +#include "mapinc.h" + +static uint8 reg; + +static SFORMAT StateRegs[] = +{ + { ®, 1, "REG" }, + { 0 } +}; + +static void Sync(void) { + setprg8(0x6000, reg); + setprg8(0x8000, 10); + setprg8(0xA000, 11); + setprg8(0xC000, 6); + setprg8(0xE000, 7); + setchr8(reg); +} + +static DECLFR(M554Read) { + if ((A >= 0xCAB6) && (A < 0xCAD7)) + { + reg = (A >> 2) & 0x0F; + Sync(); + } + else if ((A == 0xEBE2) || (A == 0xEE32)) + { + reg = (A >> 2) & 0x0F; + Sync(); + } + else if (A == 0xFFFC) + { + reg = (A >> 2) & 0x0F; + Sync(); + } + return CartBR(A); +} + +static void M554Power(void) { + Sync(); + SetReadHandler(0x6000, 0xFFFF, M554Read); +} + +static void StateRestore(int version) { + Sync(); +} + +void Mapper554_Init(CartInfo *info) { + info->Power = M554Power; + GameStateRestore = StateRestore; + AddExState(&StateRegs, ~0, 0, 0); +} diff --git a/src/ines.c b/src/ines.c index 6d811a0..b974723 100644 --- a/src/ines.c +++ b/src/ines.c @@ -706,6 +706,7 @@ INES_BOARD_BEGIN() INES_BOARD( "82112C", 540, Mapper540_Init ) INES_BOARD( "LittleCom 160-in-1", 541, Mapper541_Init ) INES_BOARD( "5-in-1 (CH-501)", 543, Mapper543_Init ) + INES_BOARD( "KS-7010", 554, Mapper554_Init ) INES_BOARD( "", 550, Mapper550_Init ) /* UNIF to NES 2.0 BOARDS */ diff --git a/src/ines.h b/src/ines.h index 24e0abb..347eeeb 100644 --- a/src/ines.h +++ b/src/ines.h @@ -274,5 +274,6 @@ void Mapper540_Init(CartInfo *); void Mapper541_Init(CartInfo *); void Mapper543_Init(CartInfo *); void Mapper550_Init(CartInfo *); +void Mapper554_Init(CartInfo *); #endif