Mapper 438: add reset-based Contra variant

This commit is contained in:
NewRisingSun
2025-09-30 20:32:09 +02:00
parent 76f40218d0
commit dfdbd64526

View File

@@ -1,8 +1,7 @@
/* FCE Ultra - NES/Famicom Emulator /* FCE Ultra - NES/Famicom Emulator
* *
* Copyright notice for this file: * Copyright notice for this file:
* Copyright (C) 2012 CaH4e3 * Copyright (C) 2025 NewRisingSun
* Copyright (C) 2002 Xodnizel
* *
* 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
@@ -18,50 +17,63 @@
* 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
*/ */
/* K-3071 */
#include "mapinc.h" #include "mapinc.h"
#include "asic_latch.h"
#include "cartram.h"
static uint8 latch[2]; static uint8 unrom;
static void Mapper438_Sync(void) { static void sync0 () {
if (latch[0] &1) if (Latch_address &0x01)
setprg32(0x8000, latch[0] >>2); setprg32(0x8000, Latch_address >>2);
else { else {
setprg16(0x8000, latch[0] >>1); setprg16(0x8000, Latch_address >>1);
setprg16(0xC000, latch[0] >>1); setprg16(0xC000, Latch_address >>1);
} }
setchr8(latch[1] >>1); setchr8(Latch_data >>1);
setmirror(latch[1] &1 ^1); setmirror(Latch_data &0x01? MI_H: MI_V);
} }
static DECLFW(Mapper438_WriteLatch) { static void sync1 () {
latch[0] =A &0xFF; int mask = ROM_size -9;
latch[1] =V; if (unrom) {
Mapper438_Sync(); mask++;
setprg16(0x8000, Latch_data &7 | mask);
setprg16(0xC000, 7 | mask);
setchr8r(0x10, 0);
setmirror(MI_V);
} else {
if (Latch_address &0x01)
setprg32(0x8000, Latch_address >>2 &(mask >>1));
else {
setprg16(0x8000, Latch_address >>1 &mask);
setprg16(0xC000, Latch_address >>1 &mask);
}
setchr8(Latch_data >>1);
setmirror(Latch_data &0x01? MI_H: MI_V);
}
} }
static void Mapper438_Reset(void) { static void power () {
latch[0] =latch[1] =0; unrom = 0;
Mapper438_Sync(); Latch_power();
} }
static void Mapper438_Power(void) { static void reset () {
latch[0] =latch[1] =0; unrom = !unrom;
Mapper438_Sync(); Latch_clear();
SetReadHandler(0x8000, 0xFFFF, CartBR);
SetWriteHandler(0x8000, 0xFFFF, Mapper438_WriteLatch);
} }
static void StateRestore(int version) { void Mapper438_Init (CartInfo *info) {
Mapper438_Sync(); if (info->submapper == 1) {
} Latch_init(info, sync1, 0x8000, 0xFFFF, NULL);
CHRRAM_init(info, 8);
void Mapper438_Init(CartInfo *info) { info->Power = power;
info->Reset = Mapper438_Reset; info->Reset = reset;
info->Power = Mapper438_Power; AddExState(&unrom, 1, 0, "UNRO");
GameStateRestore = StateRestore; } else {
AddExState(&latch, 2, 0, "LATC"); Latch_init(info, sync0, 0x8000, 0xFFFF, NULL);
info->Reset = Latch_clear;
}
} }