diff --git a/src/boards/449.c b/src/boards/449.c new file mode 100644 index 0000000..bcb17d9 --- /dev/null +++ b/src/boards/449.c @@ -0,0 +1,83 @@ +/* FCEUmm - NES/Famicom Emulator + * + * Copyright notice for this file: + * Copyright (C) 2022 + * + * 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 SFORMAT StateRegs[] = +{ + { &latchAddr, 2, "ADDR" }, + { &latchData, 1, "DATA" }, + { 0 } +}; + +static void Mapper449_Sync(void) +{ + int prg =latchAddr >>2 &0x1F | latchAddr >>3 &0x20; + if (~latchAddr &0x080) + { + setprg16(0x8000, prg); + setprg16(0xC000, prg |7); + } + else + { + if (latchAddr &0x001) + { + setprg32(0x8000, prg >>1); + } + else + { + setprg16(0x8000, prg); + setprg16(0xC000, prg); + } + } + setchr8(latchData); + setmirror(latchAddr &0x002? MI_H: MI_V); +} + +static DECLFW(Mapper449_WriteLatch) +{ + latchData =V; + latchAddr =A &0xFFFF; + Mapper449_Sync(); +} + +static void Mapper449_Reset(void) +{ + latchAddr =latchData =0; + Mapper449_Sync(); +} + +static void Mapper449_Power(void) +{ + latchAddr =latchData =0; + Mapper449_Sync(); + SetWriteHandler(0x8000, 0xFFFF, Mapper449_WriteLatch); + SetReadHandler(0x6000, 0xFFFF, CartBR); +} + +void Mapper449_Init(CartInfo *info) +{ + info->Power = Mapper449_Power; + info->Reset = Mapper449_Reset; + AddExState(StateRegs, ~0, 0, 0); +} \ No newline at end of file diff --git a/src/ines.c b/src/ines.c index c69eea0..7755137 100644 --- a/src/ines.c +++ b/src/ines.c @@ -818,6 +818,7 @@ INES_BOARD_BEGIN() INES_BOARD( "850335C", 441, Mapper441_Init ) INES_BOARD( "NC-3000M", 443, Mapper443_Init ) INES_BOARD( "NC-7000M/NC-8000M", 444, Mapper444_Init ) + INES_BOARD( "22-in-1 King Series", 449, Mapper449_Init ) INES_BOARD( "DS-9-27", 452, Mapper452_Init ) INES_BOARD( "K6C3001A", 456, Mapper456_Init ) INES_BOARD( "8-in-1", 459, Mapper459_Init ) diff --git a/src/ines.h b/src/ines.h index 988851e..ac5cc1c 100644 --- a/src/ines.h +++ b/src/ines.h @@ -326,6 +326,7 @@ void Mapper438_Init(CartInfo *); void Mapper441_Init(CartInfo *); void Mapper443_Init(CartInfo *); void Mapper444_Init(CartInfo *); +void Mapper449_Init(CartInfo *); void Mapper452_Init(CartInfo *); void Mapper456_Init(CartInfo *); void Mapper459_Init(CartInfo *);