Mapper 191: Rewrite to add multicart functionality; add submapper 1.
This commit is contained in:
73
src/boards/191.c
Normal file
73
src/boards/191.c
Normal 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(®, 1, 0, "EXPR");
|
||||||
|
}
|
||||||
@@ -1015,21 +1015,6 @@ void Mapper165_Init(CartInfo *info) {
|
|||||||
AddExState(EXPREGS, 4, 0, "EXPR");
|
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 ------------------------------- */
|
/* ---------------------------- Mapper 192 ------------------------------- */
|
||||||
|
|
||||||
static void M192CW(uint32 A, uint8 V) {
|
static void M192CW(uint32 A, uint8 V) {
|
||||||
|
|||||||
Reference in New Issue
Block a user