couple of mapper fixes (#482)
* Fix a couple of mapper issues - Implement info->Close, to free any unallocated memory (e.g. WRAM) - Add missing GameStateRestore function - Add missing state variable * Simplify header parsing * Update ines-correct.h Co-authored-by: negativeExponent <negativeExponent@users.noreply.github.com>
This commit is contained in:
@@ -25,6 +25,8 @@
|
||||
#include "mapinc.h"
|
||||
#include "../ines.h"
|
||||
|
||||
static uint8 *WRAM;
|
||||
static uint32 WRAMSIZE;
|
||||
static uint8 reg[4];
|
||||
static SFORMAT StateRegs[] =
|
||||
{
|
||||
@@ -83,20 +85,36 @@ static void reset(void)
|
||||
sync();
|
||||
}
|
||||
|
||||
static void close(void)
|
||||
{
|
||||
if (WRAM)
|
||||
FCEU_gfree(WRAM);
|
||||
WRAM = NULL;
|
||||
}
|
||||
|
||||
static void StateRestore(int version)
|
||||
{
|
||||
sync();
|
||||
}
|
||||
|
||||
void Mapper162_Init (CartInfo *info)
|
||||
{
|
||||
uint8 *WRAM;
|
||||
uint32 WRAMSIZE = info->iNES2? (info->PRGRamSize + info->PRGRamSaveSize): 8192;
|
||||
info->Power = power;
|
||||
info->Reset = reset;
|
||||
info->Close = close;
|
||||
GameHBIRQHook = hblank;
|
||||
|
||||
GameStateRestore = StateRestore;
|
||||
AddExState(StateRegs, ~0, 0, 0);
|
||||
|
||||
WRAMSIZE = info->iNES2? (info->PRGRamSize + info->PRGRamSaveSize): 8192;
|
||||
WRAM = (uint8*) FCEU_gmalloc(WRAMSIZE);
|
||||
SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1);
|
||||
AddExState(WRAM, WRAMSIZE, 0, "WRAM");
|
||||
FCEU_CheatAddRAM(WRAMSIZE >> 10, 0x6000, WRAM);
|
||||
|
||||
if (info->battery) {
|
||||
info->SaveGame[0] = WRAM;
|
||||
info->SaveGameLen[0] = info->PRGRamSaveSize;
|
||||
info->SaveGameLen[0] = WRAMSIZE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
#include "mapinc.h"
|
||||
#include "../ines.h"
|
||||
|
||||
static uint8 *WRAM;
|
||||
static uint32 WRAMSIZE;
|
||||
static uint8 reg[4];
|
||||
static SFORMAT StateRegs[] =
|
||||
{
|
||||
@@ -88,20 +90,36 @@ static void reset(void)
|
||||
sync();
|
||||
}
|
||||
|
||||
static void close(void)
|
||||
{
|
||||
if (WRAM)
|
||||
FCEU_gfree(WRAM);
|
||||
WRAM = NULL;
|
||||
}
|
||||
|
||||
static void StateRestore(int version)
|
||||
{
|
||||
sync();
|
||||
}
|
||||
|
||||
void Mapper163_Init (CartInfo *info)
|
||||
{
|
||||
uint8 *WRAM;
|
||||
uint32 WRAMSIZE = info->iNES2? (info->PRGRamSize + info->PRGRamSaveSize): 8192;
|
||||
info->Power = power;
|
||||
info->Reset = reset;
|
||||
info->Close = close;
|
||||
GameHBIRQHook = hblank;
|
||||
|
||||
GameStateRestore = StateRestore;
|
||||
AddExState(StateRegs, ~0, 0, 0);
|
||||
|
||||
WRAMSIZE = info->iNES2? (info->PRGRamSize + info->PRGRamSaveSize): 8192;
|
||||
WRAM = (uint8*) FCEU_gmalloc(WRAMSIZE);
|
||||
SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1);
|
||||
AddExState(WRAM, WRAMSIZE, 0, "WRAM");
|
||||
FCEU_CheatAddRAM(WRAMSIZE >> 10, 0x6000, WRAM);
|
||||
|
||||
if (info->battery) {
|
||||
info->SaveGame[0] = WRAM;
|
||||
info->SaveGameLen[0] = info->PRGRamSaveSize;
|
||||
info->SaveGameLen[0] = WRAMSIZE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
#include "mapinc.h"
|
||||
#include "eeprom_93C66.h"
|
||||
|
||||
static uint8 *WRAM;
|
||||
static uint32 WRAMSIZE;
|
||||
static uint8 reg[8];
|
||||
static uint8 eeprom_data[512];
|
||||
static SFORMAT StateRegs[] =
|
||||
@@ -101,16 +103,31 @@ static void reset(void)
|
||||
sync();
|
||||
}
|
||||
|
||||
static void close(void)
|
||||
{
|
||||
if (WRAM)
|
||||
FCEU_gfree(WRAM);
|
||||
WRAM = NULL;
|
||||
}
|
||||
|
||||
static void StateRestore(int version)
|
||||
{
|
||||
sync();
|
||||
}
|
||||
|
||||
void Mapper164_Init (CartInfo *info)
|
||||
{
|
||||
uint8 *WRAM;
|
||||
uint32 WRAMSIZE = info->iNES2? (info->PRGRamSize + (info->PRGRamSaveSize &~0x7FF)): 8192;
|
||||
info->Power = power;
|
||||
info->Reset = reset;
|
||||
info->Power = power;
|
||||
info->Reset = reset;
|
||||
info->Close = close;
|
||||
|
||||
GameStateRestore = StateRestore;
|
||||
AddExState(StateRegs, ~0, 0, 0);
|
||||
|
||||
WRAMSIZE = info->iNES2? (info->PRGRamSize + (info->PRGRamSaveSize &~0x7FF)): 8192;
|
||||
WRAM = (uint8*) FCEU_gmalloc(WRAMSIZE);
|
||||
SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1);
|
||||
AddExState(WRAM, WRAMSIZE, 0, "WRAM");
|
||||
FCEU_CheatAddRAM(WRAMSIZE >> 10, 0x6000, WRAM);
|
||||
|
||||
eeprom_93C66_storage = eeprom_data;
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
|
||||
#include "mapinc.h"
|
||||
|
||||
static uint8 *WRAM;
|
||||
static uint32 WRAMSIZE;
|
||||
static uint8 latch[2];
|
||||
|
||||
static void Mapper452_Sync(void) {
|
||||
@@ -62,18 +64,35 @@ static void Mapper452_Reset(void) {
|
||||
}
|
||||
|
||||
static void Mapper452_Power(void) {
|
||||
uint8* WRAM = (uint8*) FCEU_gmalloc(8192);
|
||||
|
||||
latch[0] =latch[1] =0;
|
||||
Mapper452_Sync();
|
||||
SetReadHandler(0x8000, 0xFFFF, CartBR);
|
||||
SetWriteHandler(0x8000, 0xDFFF, Mapper452_WriteLatch);
|
||||
SetWriteHandler(0xE000, 0xFFFF, CartBW);
|
||||
|
||||
SetupCartPRGMapping(0x10, (uint8*) FCEU_gmalloc(8192), 8192, 1);
|
||||
FCEU_CheatAddRAM(WRAMSIZE >> 10, 0x6000, WRAM);
|
||||
}
|
||||
|
||||
static void Mapper452_Close(void) {
|
||||
if (WRAM)
|
||||
FCEU_gfree(WRAM);
|
||||
WRAM = NULL;
|
||||
}
|
||||
|
||||
static void StateRestore(int version) {
|
||||
Mapper452_Sync();
|
||||
}
|
||||
|
||||
void Mapper452_Init(CartInfo *info) {
|
||||
info->Reset = Mapper452_Reset;
|
||||
info->Power = Mapper452_Power;
|
||||
info->Close = Mapper452_Close;
|
||||
GameStateRestore = StateRestore;
|
||||
|
||||
WRAMSIZE = 8192;
|
||||
WRAM = (uint8*) FCEU_gmalloc(WRAMSIZE);
|
||||
SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1);
|
||||
AddExState(WRAM, WRAMSIZE, 0, "WRAM");
|
||||
|
||||
AddExState(&latch, 2, 0, "LATC");
|
||||
}
|
||||
|
||||
@@ -26,6 +26,8 @@
|
||||
#include "eeprom_93C66.h"
|
||||
#include "../ines.h"
|
||||
|
||||
static uint8 *WRAM;
|
||||
static uint32 WRAMSIZE;
|
||||
static uint8 reg[4];
|
||||
static uint8 haveEEPROM;
|
||||
static uint8 eeprom_data[512];
|
||||
@@ -97,17 +99,32 @@ static void reset(void)
|
||||
sync();
|
||||
}
|
||||
|
||||
static void close(void)
|
||||
{
|
||||
if (WRAM)
|
||||
FCEU_gfree(WRAM);
|
||||
WRAM = NULL;
|
||||
}
|
||||
|
||||
static void StateRestore(int version)
|
||||
{
|
||||
sync();
|
||||
}
|
||||
|
||||
void Mapper558_Init (CartInfo *info)
|
||||
{
|
||||
uint8 *WRAM;
|
||||
uint32 WRAMSIZE = info->PRGRamSize + (info->PRGRamSaveSize &~0x7FF);
|
||||
info->Power = power;
|
||||
info->Reset = reset;
|
||||
info->Close = close;
|
||||
GameHBIRQHook = hblank;
|
||||
|
||||
GameStateRestore = StateRestore;
|
||||
AddExState(StateRegs, ~0, 0, 0);
|
||||
|
||||
WRAMSIZE = info->PRGRamSize + (info->PRGRamSaveSize &~0x7FF);
|
||||
WRAM = (uint8*) FCEU_gmalloc(WRAMSIZE);
|
||||
SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1);
|
||||
AddExState(WRAM, WRAMSIZE, 0, "WRAM");
|
||||
FCEU_CheatAddRAM(WRAMSIZE >> 10, 0x6000, WRAM);
|
||||
haveEEPROM =!!(info->PRGRamSaveSize &0x200);
|
||||
if (haveEEPROM)
|
||||
|
||||
@@ -139,6 +139,12 @@ static void UNLKS7032Power(void) {
|
||||
}
|
||||
}
|
||||
|
||||
static void UNLKS7032Close(void) {
|
||||
if (WRAM)
|
||||
FCEU_gfree(WRAM);
|
||||
WRAM = NULL;
|
||||
}
|
||||
|
||||
static void StateRestore(int version) {
|
||||
Sync();
|
||||
}
|
||||
@@ -146,6 +152,7 @@ static void StateRestore(int version) {
|
||||
void UNLKS7032_Init(CartInfo *info) {
|
||||
KS7032 = 1;
|
||||
info->Power = UNLKS7032Power;
|
||||
info->Close = UNLKS7032Close;
|
||||
MapIRQHook = UNLSMB2JIRQHook;
|
||||
GameStateRestore = StateRestore;
|
||||
AddExState(&StateRegsKS7032, ~0, 0, 0);
|
||||
@@ -154,6 +161,7 @@ void UNLKS7032_Init(CartInfo *info) {
|
||||
void UNLKS202_Init(CartInfo *info) {
|
||||
KS7032 = 0;
|
||||
info->Power = UNLKS7032Power;
|
||||
info->Close = UNLKS7032Close;
|
||||
MapIRQHook = UNLSMB2JIRQHook;
|
||||
GameStateRestore = StateRestore;
|
||||
AddExState(&StateRegsKS7032, ~0, 0, 0);
|
||||
|
||||
@@ -409,6 +409,13 @@ static void JYASIC_reset (void)
|
||||
dipSwitch = (dipSwitch +0x40) &0xC0;
|
||||
}
|
||||
|
||||
static void JYASIC_close (void)
|
||||
{
|
||||
if (WRAM)
|
||||
FCEU_gfree(WRAM);
|
||||
WRAM = NULL;
|
||||
}
|
||||
|
||||
static void JYASIC_restore (int version)
|
||||
{
|
||||
sync();
|
||||
@@ -418,6 +425,7 @@ void JYASIC_init (CartInfo *info)
|
||||
{
|
||||
info->Reset = JYASIC_reset;
|
||||
info->Power = JYASIC_power;
|
||||
info->Close = JYASIC_close;
|
||||
PPU_hook = trapPPUAddressChange;
|
||||
MapIRQHook = cpuCycle;
|
||||
GameHBIRQHook2 = ppuScanline;
|
||||
|
||||
Reference in New Issue
Block a user