Mapper 460: Rewrite and correct submapper-specific solder pad menu selection.

This commit is contained in:
NewRisingSun
2025-09-09 21:15:43 +02:00
parent c124b6bc6d
commit 5c3fa225ee

View File

@@ -1,7 +1,7 @@
/* FCEUmm - NES/Famicom Emulator /* FCEUmm - NES/Famicom Emulator
* *
* Copyright notice for this file: * Copyright notice for this file:
* Copyright (C) 2022 * Copyright (C) 2020
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -16,79 +16,81 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*
*/ */
#include "mapinc.h" #include "mapinc.h"
#include "mmc3.h" #include "asic_mmc3.h"
static uint8 *CHRRAM =NULL; static uint8 submapper;
static uint8 reg;
static uint8 pad;
static uint8 *CHRRAM = NULL;
static DECLFR(Mapper460_ReadOB) static DECLFR (readPad) {
{ return CartBR(A &~3 | pad &3);
return X.DB;
} }
static void Mapper460_PRGWrap(uint32 A, uint8 V) { static void sync () {
int prgAND =0x0F; MMC3_syncPRG(0x0F, reg <<4 &~0x0F);
int prgOR =EXPREGS[0] <<4; if (reg &0x04)
if (EXPREGS[0] &0x38) { /* Menu selection by selectively connecting CPU D7 to reg or not */ MMC3_syncCHR(0x1FF, 0x000);
if (~A &0x4000) {
setprg8(A, (EXPREGS[0] &0x10? ~2: ~0) &V &prgAND | prgOR &~prgAND);
setprg8(A |0x4000, (EXPREGS[0] &0x10? 2: 0) |V &prgAND | prgOR &~prgAND);
}
} else
setprg8(A, V &prgAND | prgOR &~prgAND);
/* Menu selection by selectively connecting reg's D7 to PRG /CE or not */
if (EXPREGS[0] &0x80 && EXPREGS[1] &1)
SetReadHandler(0x8000, 0xFFFF, Mapper460_ReadOB);
else else
SetReadHandler(0x8000, 0xFFFF, CartBR);
}
static void Mapper460_CHRWrap(uint32 A, uint8 V) {
if (EXPREGS[0] &0x04) {
setchr2(0x0000, DRegBuf[0] &0xFE);
setchr2(0x0800, DRegBuf[0] |0x01);
setchr2(0x1000, DRegBuf[2]);
setchr2(0x1800, DRegBuf[5]);
} else
setchr8r(0x10, 0); setchr8r(0x10, 0);
MMC3_syncMirror();
SetReadHandler(0x8000, 0xFFFF, submapper == 0 && reg &0x80 || submapper == 1 && reg &0x20? readPad: CartBR);
} }
static DECLFW(Mapper460_WriteExtra) { static int getPRGBank (uint8 bank) {
if (A001B &0x80 && ~A001B &0x40) EXPREGS[0] =A &0xFF; if (reg &0x08) {
FixMMC3PRG(MMC3_cmd); int mask = reg &0x10? 3: 1;
FixMMC3CHR(MMC3_cmd); return MMC3_getPRGBank(bank &1) &~mask | bank &mask;
} else
return MMC3_getPRGBank(bank);
} }
static void Mapper460_Reset(void) { static int getCHRBank (uint8 bank) {
EXPREGS[0] =0; if (reg &0x04)
EXPREGS[1]++; return MMC3_getCHRBank(bank &6 | bank >>1 &1) <<1 | bank &1;
MMC3RegReset(); else
return MMC3_getCHRBank(bank);
} }
static void Mapper460_Power(void) { static DECLFW (writeReg) {
EXPREGS[0] =0; reg = A &0xFF;
EXPREGS[1] =0; sync();
GenMMC3Power();
SetWriteHandler(0x6000, 0x7FFF, Mapper460_WriteExtra);
} }
static void Mapper460_close(void) { static void reset () {
if (CHRRAM) FCEU_gfree(CHRRAM); reg = 0;
CHRRAM =NULL; pad++;
MMC3_clear();
} }
void Mapper460_Init(CartInfo *info) { static void power () {
GenMMC3_Init(info, 128, 512, 0, 0); reg = 0;
cwrap = Mapper460_CHRWrap; pad = 0;
pwrap = Mapper460_PRGWrap; MMC3_power();
info->Power = Mapper460_Power; }
info->Reset = Mapper460_Reset;
info->Close = Mapper460_close; static void close () {
AddExState(EXPREGS, 2, 0, "EXPR"); if (CHRRAM) {
FCEU_gfree(CHRRAM);
CHRRAM =(uint8 *)FCEU_gmalloc(8192); CHRRAM = NULL;
}
}
void Mapper460_Init (CartInfo *info) {
submapper = info->submapper;
MMC3_init(info, sync, MMC3_TYPE_SHARP, getPRGBank, getCHRBank, NULL, writeReg);
info->Power = power;
info->Reset = reset;
info->Close = close;
AddExState(&reg, 1, 0, "EXPR");
AddExState(&reg, 1, 0, "DIPS");
CHRRAM = (uint8 *)FCEU_gmalloc(8192);
SetupCartCHRMapping(0x10, CHRRAM, 8192, 1); SetupCartCHRMapping(0x10, CHRRAM, 8192, 1);
AddExState(CHRRAM, 8192, 0, "CRAM"); AddExState(CHRRAM, 8192, 0, "CRAM");
} }