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:
negativeExponent
2022-01-24 02:20:46 +08:00
committed by GitHub
parent eb06d17e79
commit 758a51eacb
9 changed files with 157 additions and 61 deletions

View File

@@ -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;