diff --git a/src/boards/236.c b/src/boards/236.c new file mode 100644 index 0000000..f4af1c9 --- /dev/null +++ b/src/boards/236.c @@ -0,0 +1,99 @@ +/* FCE Ultra - NES/Famicom Emulator + * + * Copyright notice for this file: + * Copyright (C) 2012 CaH4e3 + * + * 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[2]; +static uint8 dip; +static SFORMAT StateRegs[] = +{ + { reg, 2, "REG " }, + { &dip, 1, "DIP " }, + { 0 } +}; + +static void Sync(void) +{ + int prg = reg[1] &7 | reg[0] <<3; + switch (reg[1] >>4 &3) + { + case 0: + case 1: + setprg16(0x8000, prg); + setprg16(0xC000, prg |7); + break; + case 2: + setprg32(0x8000, prg >>1); + break; + case 3: + setprg16(0x8000, prg); + setprg16(0xC000, prg); + break; + } + setchr8(reg[0] &7); + setmirror((reg[0] >>5 &1) ^1); +} + + +static DECLFR(M236Read) +{ + if ((reg[1] >>4 &3) ==1) + return CartBR(A &~0xF | dip); + else + return CartBR(A); +} + +static DECLFW(M236WriteReg) +{ + reg[A >>14 &1] =A &0xFF; + Sync(); +} + +static void M236Power(void) +{ + dip = 0; + reg[0] = 0; + reg[1] = 0; + Sync(); + SetWriteHandler(0x8000, 0xFFFF, M236WriteReg); + SetReadHandler(0x8000, 0xFFFF, M236Read); +} + +static void M236Reset(void) +{ + ++dip; + /* Soft-reset returns to menu */ + reg[0] = 0; + reg[1] = 0; + Sync(); +} + +static void StateRestore(int version) +{ + Sync(); +} + +void Mapper236_Init(CartInfo *info) +{ + info->Power = M236Power; + info->Reset = M236Reset; + AddExState(&StateRegs, ~0, 0, 0); + GameStateRestore = StateRestore; +} diff --git a/src/ines.c b/src/ines.c index 973d875..1e7f7f0 100644 --- a/src/ines.c +++ b/src/ines.c @@ -655,7 +655,7 @@ INES_BOARD_BEGIN() INES_BOARD( "BMC 22+20-in-1 RST", 233, Mapper233_Init ) INES_BOARD( "BMC MAXI", 234, Mapper234_Init ) INES_BOARD( "Golden Game", 235, Mapper235_Init ) -/* INES_BOARD( "", 236, Mapper236_Init ) */ + INES_BOARD( "Realtec 8155", 236, Mapper236_Init ) INES_BOARD( "Teletubbies / Y2K", 237, Mapper237_Init ) INES_BOARD( "UNL6035052", 238, UNL6035052_Init ) /* INES_BOARD( "", 239, Mapper239_Init ) */