Mapper 191: Rewrite to add multicart functionality; add submapper 1.

This commit is contained in:
NewRisingSun
2025-11-02 10:46:56 +01:00
parent 65cf86e148
commit 4070514256
2 changed files with 73 additions and 15 deletions

73
src/boards/191.c Normal file
View File

@@ -0,0 +1,73 @@
/* FCEUmm - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2025 NewRisingSun
*
* 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 "asic_mmc3.h"
#include "cartram.h"
static uint8 submapper;
static uint8 reg;
static void sync () {
int bank;
MMC3_syncWRAM(0);
MMC3_syncPRG(0x3F, 0);
if ((reg &0x03) == 0x03) for (bank = 0; bank < 8; bank++) {
int val = MMC3_getCHRBank(bank);
setchr1r(val &0x80? 0x10: 0x00, bank <<10, val &0x7F);
} else
MMC3_syncCHR(0x7F, 0x80);
MMC3_syncMirror();
}
static int getPRGBank (uint8 bank) {
if (bank &2)
return MMC3_getPRGBank(bank) &~6 | reg <<1 &6;
else
return MMC3_getPRGBank(bank);
}
static DECLFW (writeReg) {
reg = V;
sync();
}
static void reset () {
RAM[0x110] =0;
reg = submapper == 1? 0x00: 0x03;
MMC3_clear();
}
static void power () {
MMC3_power();
SetWriteHandler(0x90AA, 0x90AA, writeReg);
reset();
}
void Mapper191_Init (CartInfo *info) {
submapper = info->submapper;
MMC3_init(info, sync, MMC3_TYPE_SHARP, getPRGBank, NULL, NULL, NULL);
CartRAM_init(info, 8, 2);
info->Power = power;
info->Reset = reset;
AddExState(&reg, 1, 0, "EXPR");
}

View File

@@ -1015,21 +1015,6 @@ void Mapper165_Init(CartInfo *info) {
AddExState(EXPREGS, 4, 0, "EXPR");
}
/* ---------------------------- Mapper 191 ------------------------------ */
static void M191CW(uint32 A, uint8 V) {
setchr1r((V & 0x80) >> 3, A, V);
}
void Mapper191_Init(CartInfo *info) {
GenMMC3_Init(info, 256, 256, 8, info->battery);
cwrap = M191CW;
CHRRAMSIZE = 2048;
CHRRAM = (uint8*)FCEU_gmalloc(CHRRAMSIZE);
SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSIZE, 1);
AddExState(CHRRAM, CHRRAMSIZE, 0, "CHRR");
}
/* ---------------------------- Mapper 192 ------------------------------- */
static void M192CW(uint32 A, uint8 V) {