diff --git a/src/boards/277.c b/src/boards/277.c new file mode 100644 index 0000000..4f6549c --- /dev/null +++ b/src/boards/277.c @@ -0,0 +1,64 @@ +/* FCE Ultra - NES/Famicom Emulator + * + * Copyright notice for this file: + * Copyright (C) 2006 CaH4e3 + * Copyright (C) 2023 + * + * 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 "latch.h" + +static void Sync(void) { + if (!(latch.data & 1) && (latch.data & 8)) { + setprg16(0x8000, latch.data & ~1); + setprg16(0xC000, latch.data | 1); + } else { + if (latch.data & 8) { + setprg16(0x8000, latch.data); + setprg16(0xC000, latch.data); + } else { + setprg16(0x8000, latch.data); + setprg16(0xC000, latch.data | 7); + } + } + setchr8(0); + setmirror(((latch.data >> 4) & 1) ^ 1); +} + +static DECLFW(M277Write) { + if (!(latch.data & 0x20)) { + LatchWrite(A, V); + } +} + +static void M277Power(void) { + LatchPower(); + latch.data = 8; + Sync(); + SetWriteHandler(0x8000, 0xFFFF, M277Write); +} + +static void M277Reset() { + latch.data = 0x08; + Sync(); +} + +void Mapper277_Init(CartInfo *info) { + Latch_Init(info, Sync, NULL, 0, 0); + info->Power = M277Power; + info->Reset = M277Reset; +} diff --git a/src/ines.c b/src/ines.c index 66efaba..b7f29d4 100644 --- a/src/ines.c +++ b/src/ines.c @@ -696,6 +696,7 @@ INES_BOARD_BEGIN() INES_BOARD( "MGC-026", 271, Mapper271_Init ) INES_BOARD( "Akumajō Special: Boku Dracula-kun", 272, Mapper272_Init ) INES_BOARD( "80013-B", 274, BMC80013B_Init ) + INES_BOARD( "", 277, Mapper277_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 18430d4..2c339ba 100644 --- a/src/ines.h +++ b/src/ines.h @@ -249,6 +249,7 @@ void Mapper255_Init(CartInfo *); void GN45_Init(CartInfo *info); /* m361, m366 */ void Mapper272_Init(CartInfo *); +void Mapper277_Init(CartInfo *); void Mapper281_Init(CartInfo *); void Mapper282_Init(CartInfo *); void Mapper283_Init(CartInfo *);