Add submappers to mapper 396.

This commit is contained in:
NewRisingSun
2025-09-12 13:23:26 +02:00
parent 81cfd57103
commit 2f7bb51349
2 changed files with 39 additions and 41 deletions

View File

@@ -1,7 +1,7 @@
/* FCEUmm - NES/Famicom Emulator
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2022
* 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
@@ -16,58 +16,56 @@
* 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
*
* NES 2.0 Mapper 396 - BMC-830752C
* 1995 Super 8-in-1 (JY-050 rev0)
* Super 8-in-1 Gold Card Series (JY-085)
* Super 8-in-1 Gold Card Series (JY-086)
* 2-in-1 (GN-51)
*/
#include "mapinc.h"
static uint8 submapper;
static uint8 reg[2];
static void Sync (void) {
setprg16(0x8000, reg[1] << 3 | reg[0] & 7);
setprg16(0xC000, reg[1] << 3 | 7);
static void sync () {
setprg16(0x8000, reg[0] <<3 | reg[1] &0x07);
setprg16(0xC000, reg[0] <<3 | 0x07);
setchr8(0);
setmirror(reg[1] & 0x60 ? 0 : 1);
switch(submapper) {
case 1: /* J.Y. YY850437C */
setmirror(reg[0] &0x40? MI_H: MI_V);
break;
case 2: /* Realtec GN-51 */
case 3: /* Realtec 8030 */
setmirror(reg[0] &0x20? MI_H: MI_V);
break;
default:
setmirror(reg[0] &0x60? MI_H: MI_V);
break;
}
}
static DECLFW(M396WriteInnerBank) {
reg[0] = V;
Sync();
static DECLFW (writeReg) {
reg[(A &0xE000) == 0xA000? 0: 1] = V;
sync();
}
static DECLFW(M396WriteOuterBank) {
reg[1] = V;
Sync();
static DECLFW (writeReg_submapper3) {
reg[A >>14 &1] = V;
sync();
}
static void M396Reset(void) {
reg[0] = 0x00;
reg[1] = 0x00;
Sync();
static void power () {
SetReadHandler(0x6000, 0xFFFF, CartBR);
SetWriteHandler(0x8000, 0xFFFF, submapper == 3? writeReg_submapper3: writeReg);
reg[0] = reg[1] = 0;
sync();
}
static void StateRestore(int version) {
Sync();
static void stateRestore (int version) {
sync();
}
static void M396Power(void) {
reg[0] = 0x00;
reg[1] = 0x00;
Sync();
SetReadHandler(0x8000, 0xFFFF, CartBR);
SetWriteHandler(0x8000, 0x9FFF, M396WriteInnerBank);
SetWriteHandler(0xA000, 0xBFFF, M396WriteOuterBank);
SetWriteHandler(0xC000, 0xFFFF, M396WriteInnerBank);
}
void Mapper396_Init(CartInfo *info) {
info->Power = M396Power;
info->Reset = M396Reset;
GameStateRestore = StateRestore;
void Mapper396_Init (CartInfo *info) {
submapper = info->submapper;
info->Power = power;
info->Reset = submapper == 3? sync: power;
GameStateRestore = stateRestore;
AddExState(reg, 2, 0, "REGS");
}

View File

@@ -29,19 +29,19 @@ static void sync () {
setmirror(reg[0] &0x80? MI_H: MI_V);
}
static DECLFW(writeReg) {
static DECLFW (writeReg) {
reg[A >>12 &1] = V;
sync();
}
static void power() {
static void power () {
SetReadHandler(0x6000, 0xFFFF, CartBR);
SetWriteHandler(0xE000, 0xFFFF, writeReg);
reg[0] = reg[1] = 0;
sync();
}
static void stateRestore(int version) {
static void stateRestore (int version) {
sync();
}