From 8073cfba7e2d21bc69290d86e0ad01b31162103f Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Sun, 11 Oct 2020 22:47:48 +0800 Subject: [PATCH] Add mapper 411 --- src/boards/411.c | 85 ++++++++++++++++++++++++++++++++++++++++++++++++ src/ines.c | 1 + src/ines.h | 1 + 3 files changed, 87 insertions(+) create mode 100644 src/boards/411.c diff --git a/src/boards/411.c b/src/boards/411.c new file mode 100644 index 0000000..eafa3cc --- /dev/null +++ b/src/boards/411.c @@ -0,0 +1,85 @@ +/* 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 411 - A88S-1 + * 1997 Super 7-in-1 (JY-201) + * 1997 Super 6-in-1 (JY-202) + * 1997 Super 7-in-1 (JY-203) + * 1997 龍珠武鬥會 7-in-1 (JY-204) + * 1997 Super 7-in-1 (JY-205) + * 1997 Super 7-in-1 (JY-206) + */ + +#include "mapinc.h" +#include "mmc3.h" + +static void M411CW(uint32 A, uint8 V) { + uint32 mask = (EXPREGS[1] & 2) ? 0xFF : 0x7F; + V &= mask; + setchr1(A, V | ((EXPREGS[1] << 5) & 0x80) | ((EXPREGS[0] << 4) & 0x100)); +} + +static void M411PW(uint32 A, uint8 V) { + /* NROM Mode */ + if (EXPREGS[0] & 0x40) + { + uint32 bank = (EXPREGS[0] & 1) | ((EXPREGS[0] >> 2) & 2) | (EXPREGS[0] & 4) | (EXPREGS[1] & 8) | ((EXPREGS[1] >> 2) & 0x10); + + /* NROM-256 */ + if (EXPREGS[0] & 0x02) { + setprg32(0x8000, bank >> 1); + + /* NROM-128 */ + } else { + setprg16(0x8000, bank); + setprg16(0xC000, bank); + } + } + + /* MMC3 Mode */ + else + { + uint32 mask = (EXPREGS[1] & 2) ? 0x1F : 0x0F; + V &= mask; + setprg8(A, V | ((EXPREGS[1] << 1) & 0x10) | ((EXPREGS[1] >> 1) & 0x20)); + } +} + +static DECLFW(M411Write5000) { + EXPREGS[A & 1] = V; + FixMMC3PRG(MMC3_cmd); + FixMMC3CHR(MMC3_cmd); +} + +static void M411Power(void) { + EXPREGS[0] = 0x80; + EXPREGS[1] = 0x82; + GenMMC3Power(); + SetWriteHandler(0x5000, 0x5FFF, M411Write5000); +} + +void Mapper411_Init(CartInfo *info) { + GenMMC3_Init(info, 256, 256, 0, 0); + pwrap = M411PW; + cwrap = M411CW; + info->Power = M411Power; + AddExState(EXPREGS, 2, 0, "EXPR"); +} diff --git a/src/ines.c b/src/ines.c index 6d811a0..8897dab 100644 --- a/src/ines.c +++ b/src/ines.c @@ -698,6 +698,7 @@ INES_BOARD_BEGIN() INES_BOARD( "830928C", 382, Mapper382_Init ) INES_BOARD( "Caltron 9-in-1", 389, Mapper389_Init ) INES_BOARD( "Realtec 8031", 390, Mapper390_Init ) + INES_BOARD( "A88S-1", 411, Mapper411_Init ) INES_BOARD( "Brilliant Com Cocoma Pack", 516, Mapper516_Init ) INES_BOARD( "Sachen 3014", 533, Mapper533_Init ) INES_BOARD( "NJ064", 534, Mapper534_Init ) diff --git a/src/ines.h b/src/ines.h index 24e0abb..3f40b06 100644 --- a/src/ines.h +++ b/src/ines.h @@ -265,6 +265,7 @@ void Mapper381_Init(CartInfo *); void Mapper382_Init(CartInfo *); void Mapper389_Init(CartInfo *); void Mapper390_Init(CartInfo *); +void Mapper411_Init(CartInfo *); void Mapper516_Init(CartInfo *); void Mapper533_Init(CartInfo *); void Mapper534_Init(CartInfo *);