From 872acac367ae5eb48613a75b3649e644ca14f18f Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Thu, 20 Feb 2020 12:07:38 +0800 Subject: [PATCH] Merge mapper 225 and 255, re-implement extra RAM - merges mappers 225 and 255 since they are basically the same - re-implement extra RAM as its required for some multicarts --- src/boards/225.c | 20 ++++++++++-- src/boards/255.c | 79 ------------------------------------------------ 2 files changed, 17 insertions(+), 82 deletions(-) delete mode 100644 src/boards/255.c diff --git a/src/boards/225.c b/src/boards/225.c index 2fb9768..12576d5 100644 --- a/src/boards/225.c +++ b/src/boards/225.c @@ -2,6 +2,8 @@ * * Copyright notice for this file: * Copyright (C) 2011 CaH4e3 + * Copyright (C) 2019 Libretro Team + * 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 @@ -19,15 +21,20 @@ * * PCB-018 board, discrete multigame cart 110-in-1 * + * Mapper 225 + * Mapper 255 + * */ +/* 2020-2-20 - merge mapper 255, re-implement extra RAM */ + #include "mapinc.h" -static uint8 prot[4], prg, mode, chr, mirr; +static uint8 extraRAM[4], prg, mode, chr, mirr; static SFORMAT StateRegs[] = { - { prot, 4, "PROT" }, + { extraRAM, 4, "PROT" }, { &prg, 1, "PRG" }, { &chr, 1, "CHR" }, { &mode, 1, "MODE" }, @@ -55,10 +62,13 @@ static DECLFW(M225Write) { } static DECLFW(M225LoWrite) { + /* e.g. 115-in-1 [p1][!] CRC32 0xb39d30b4 */ + if (A & 0x800) extraRAM[A & 3] = V & 0x0F; } static DECLFR(M225LoRead) { - return 0; + if (A & 0x800) return extraRAM[A & 3]; + return X.DB; } static void M225Power(void) { @@ -87,3 +97,7 @@ void Mapper225_Init(CartInfo *info) { GameStateRestore = StateRestore; AddExState(&StateRegs, ~0, 0, 0); } + +void Mapper255_Init(CartInfo *info) { + Mapper225_Init(info); +} \ No newline at end of file diff --git a/src/boards/255.c b/src/boards/255.c deleted file mode 100644 index fc7f28c..0000000 --- a/src/boards/255.c +++ /dev/null @@ -1,79 +0,0 @@ -/* FCEUmm - NES/Famicom Emulator - * - * Copyright (C) 2019 Libretro Team - * - * 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 - */ - -/* added 2019-5-23 - * Mapper 255 - * https://wiki.nesdev.com/w/index.php/INES_Mapper_225 - * 115-in-1 [p1][!] CRC32 0xb39d30b4 - * Seems to handle up to last game in the multicarts than m225 but causes - * graphics garbage past it, else games works fine */ - -#include "mapinc.h" - -static uint8 preg, creg, mode, mirr; - -static SFORMAT StateRegs[] = -{ - { &preg, 1, "PRG0" }, - { &creg, 1, "CHR0" }, - { &mode, 1, "MODE" }, - { &mirr, 1, "MIRR" }, - { 0 } -}; - -static void Sync(void) { - setprg16(0x8000, preg & ~mode); - setprg16(0xC000, preg | mode); - setchr8(creg); - setmirror(mirr ^ 1); -} - -static DECLFW(M255Write) { - uint32 bank = (A >> 8 & 0x40); - preg = bank | ((A >> 6) & 0x3F); - creg = bank | (A & 0x3F); - mirr = (A >> 13) & 1; - mode = ((~A) >> 12 & 1); - Sync(); -} - -static void M255Power(void) { - preg = 0; - mode = 1; - Sync(); - SetReadHandler(0x8000, 0xFFFF, CartBR); - SetWriteHandler(0x8000, 0xFFFF, M255Write); -} - -static void M255Reset(void) { - preg = 0; - mode = 1; - Sync(); -} - -static void StateRestore(int version) { - Sync(); -} - -void Mapper255_Init(CartInfo *info) { - info->Reset = M255Reset; - info->Power = M255Power; - GameStateRestore = StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -}