mapper 018 - fixed

mapper 198 - fixed
AutoResumePlay default option - "disabled"
This commit is contained in:
CaH4e3 2012-12-18 13:56:35 +00:00
parent e1ef50ac14
commit 8110346ccb
4 changed files with 79 additions and 75 deletions

View File

@ -23,6 +23,8 @@
static uint8 preg[4], creg[8]; static uint8 preg[4], creg[8];
static uint8 IRQa, mirr; static uint8 IRQa, mirr;
static int32 IRQCount, IRQLatch; static int32 IRQCount, IRQLatch;
static uint8 *WRAM = NULL;
static uint32 WRAMSIZE;
static SFORMAT StateRegs[] = static SFORMAT StateRegs[] =
{ {
@ -38,6 +40,7 @@ static SFORMAT StateRegs[] =
static void Sync(void) { static void Sync(void) {
int i; int i;
for (i = 0; i < 8; i++) setchr1(i << 10, creg[i]); for (i = 0; i < 8; i++) setchr1(i << 10, creg[i]);
setprg8r(0x10, 0x6000, 0);
setprg8(0x8000, preg[0]); setprg8(0x8000, preg[0]);
setprg8(0xA000, preg[1]); setprg8(0xA000, preg[1]);
setprg8(0xC000, preg[2]); setprg8(0xC000, preg[2]);
@ -75,12 +78,14 @@ static DECLFW(M18WriteChr) {
} }
static void M18Power(void) { static void M18Power(void) {
IRQa = 0;
preg[0] = 0; preg[0] = 0;
preg[1] = 1; preg[1] = 1;
preg[2] = ~1; preg[2] = ~1;
preg[3] = ~0; preg[3] = ~0;
Sync(); Sync();
SetReadHandler(0x8000, 0xFFFF, CartBR); SetReadHandler(0x6000, 0xFFFF, CartBR);
SetWriteHandler(0x6000, 0x7FFF, CartBW);
SetWriteHandler(0x8000, 0x9FFF, M18WritePrg); SetWriteHandler(0x8000, 0x9FFF, M18WritePrg);
SetWriteHandler(0xA000, 0xDFFF, M18WriteChr); SetWriteHandler(0xA000, 0xDFFF, M18WriteChr);
SetWriteHandler(0xE000, 0xFFFF, M18WriteIRQ); SetWriteHandler(0xE000, 0xFFFF, M18WriteIRQ);
@ -97,15 +102,32 @@ static void M18IRQHook(int a) {
} }
} }
static void M18Close(void)
{
if (WRAM)
FCEU_gfree(WRAM);
WRAM = NULL;
}
static void StateRestore(int version) { static void StateRestore(int version) {
Sync(); Sync();
} }
void Mapper18_Init(CartInfo *info) { void Mapper18_Init(CartInfo *info) {
info->Power = M18Power; info->Power = M18Power;
info->Close = M18Close;
MapIRQHook = M18IRQHook; MapIRQHook = M18IRQHook;
GameStateRestore = StateRestore; GameStateRestore = StateRestore;
WRAMSIZE = 8192;
WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE);
SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1);
AddExState(WRAM, WRAMSIZE, 0, "WRAM");
if (info->battery) {
info->SaveGame[0] = WRAM;
info->SaveGameLen[0] = WRAMSIZE;
}
AddExState(&StateRegs, ~0, 0, 0); AddExState(&StateRegs, ~0, 0, 0);
} }

View File

@ -29,8 +29,9 @@
uint8 MMC3_cmd; uint8 MMC3_cmd;
uint8 *WRAM; uint8 *WRAM;
uint32 WRAMSIZE;
uint8 *CHRRAM; uint8 *CHRRAM;
uint32 CHRRAMSize; uint32 CHRRAMSIZE;
uint8 DRegBuf[8]; uint8 DRegBuf[8];
uint8 EXPREGS[8]; /* For bootleg games, mostly. */ uint8 EXPREGS[8]; /* For bootleg games, mostly. */
uint8 A000B, A001B; uint8 A000B, A001B;
@ -55,7 +56,6 @@ static SFORMAT MMC3_StateRegs[] =
{ 0 } { 0 }
}; };
static int wrams;
static int isRevB = 1; static int isRevB = 1;
void (*pwrap)(uint32 A, uint8 V); void (*pwrap)(uint32 A, uint8 V);
@ -249,22 +249,22 @@ void GenMMC3Power(void) {
A001B = A000B = 0; A001B = A000B = 0;
setmirror(1); setmirror(1);
if (mmc3opts & 1) { if (mmc3opts & 1) {
if (wrams == 1024) { if (WRAMSIZE == 1024) {
FCEU_CheatAddRAM(1, 0x7000, WRAM); FCEU_CheatAddRAM(1, 0x7000, WRAM);
SetReadHandler(0x7000, 0x7FFF, MAWRAMMMC6); SetReadHandler(0x7000, 0x7FFF, MAWRAMMMC6);
SetWriteHandler(0x7000, 0x7FFF, MBWRAMMMC6); SetWriteHandler(0x7000, 0x7FFF, MBWRAMMMC6);
} else { } else {
FCEU_CheatAddRAM((wrams & 0x1fff) >> 10, 0x6000, WRAM); FCEU_CheatAddRAM((WRAMSIZE & 0x1fff) >> 10, 0x6000, WRAM);
SetWriteHandler(0x6000, 0x6000 + ((wrams - 1) & 0x1fff), CartBW); SetWriteHandler(0x6000, 0x6000 + ((WRAMSIZE - 1) & 0x1fff), CartBW);
SetReadHandler(0x6000, 0x6000 + ((wrams - 1) & 0x1fff), CartBR); SetReadHandler(0x6000, 0x6000 + ((WRAMSIZE - 1) & 0x1fff), CartBR);
setprg8r(0x10, 0x6000, 0); setprg8r(0x10, 0x6000, 0);
} }
if (!(mmc3opts & 2)) if (!(mmc3opts & 2))
FCEU_dwmemset(WRAM, 0, wrams); FCEU_dwmemset(WRAM, 0, WRAMSIZE);
} }
MMC3RegReset(); MMC3RegReset();
if (CHRRAM) if (CHRRAM)
FCEU_dwmemset(CHRRAM, 0, CHRRAMSize); FCEU_dwmemset(CHRRAM, 0, CHRRAMSIZE);
} }
static void GenMMC3Close(void) { static void GenMMC3Close(void) {
@ -280,7 +280,7 @@ void GenMMC3_Init(CartInfo *info, int prg, int chr, int wram, int battery) {
cwrap = GENCWRAP; cwrap = GENCWRAP;
mwrap = GENMWRAP; mwrap = GENMWRAP;
wrams = wram << 10; WRAMSIZE = wram << 10;
PRGmask8[0] &= (prg >> 13) - 1; PRGmask8[0] &= (prg >> 13) - 1;
CHRmask1[0] &= (chr >> 10) - 1; CHRmask1[0] &= (chr >> 10) - 1;
@ -288,15 +288,15 @@ void GenMMC3_Init(CartInfo *info, int prg, int chr, int wram, int battery) {
if (wram) { if (wram) {
mmc3opts |= 1; mmc3opts |= 1;
WRAM = (uint8*)FCEU_gmalloc(wrams); WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE);
SetupCartPRGMapping(0x10, WRAM, wrams, 1); SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1);
AddExState(WRAM, wrams, 0, "MRAM"); AddExState(WRAM, WRAMSIZE, 0, "WRAM");
} }
if (battery) { if (battery) {
mmc3opts |= 2; mmc3opts |= 2;
info->SaveGame[0] = WRAM; info->SaveGame[0] = WRAM;
info->SaveGameLen[0] = wrams; info->SaveGameLen[0] = WRAMSIZE;
} }
AddExState(MMC3_StateRegs, ~0, 0, 0); AddExState(MMC3_StateRegs, ~0, 0, 0);
@ -668,10 +668,10 @@ static void M74CW(uint32 A, uint8 V) {
void Mapper74_Init(CartInfo *info) { void Mapper74_Init(CartInfo *info) {
GenMMC3_Init(info, 512, 256, 8, info->battery); GenMMC3_Init(info, 512, 256, 8, info->battery);
cwrap = M74CW; cwrap = M74CW;
CHRRAMSize = 2048; CHRRAMSIZE = 2048;
CHRRAM = (uint8*)FCEU_gmalloc(CHRRAMSize); CHRRAM = (uint8*)FCEU_gmalloc(CHRRAMSIZE);
SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSize, 1); SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSIZE, 1);
AddExState(CHRRAM, CHRRAMSize, 0, "CHRR"); AddExState(CHRRAM, CHRRAMSIZE, 0, "CHRR");
} }
// ---------------------------- Mapper 114 ------------------------------ // ---------------------------- Mapper 114 ------------------------------
@ -799,9 +799,9 @@ static void TQWRAP(uint32 A, uint8 V) {
void Mapper119_Init(CartInfo *info) { void Mapper119_Init(CartInfo *info) {
GenMMC3_Init(info, 512, 64, 0, 0); GenMMC3_Init(info, 512, 64, 0, 0);
cwrap = TQWRAP; cwrap = TQWRAP;
CHRRAMSize = 8192; CHRRAMSIZE = 8192;
CHRRAM = (uint8*)FCEU_gmalloc(CHRRAMSize); CHRRAM = (uint8*)FCEU_gmalloc(CHRRAMSIZE);
SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSize, 1); SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSIZE, 1);
} }
// ---------------------------- Mapper 134 ------------------------------ // ---------------------------- Mapper 134 ------------------------------
@ -890,10 +890,10 @@ void Mapper165_Init(CartInfo *info) {
cwrap = M165CWM; cwrap = M165CWM;
PPU_hook = M165PPU; PPU_hook = M165PPU;
info->Power = M165Power; info->Power = M165Power;
CHRRAMSize = 4096; CHRRAMSIZE = 4096;
CHRRAM = (uint8*)FCEU_gmalloc(CHRRAMSize); CHRRAM = (uint8*)FCEU_gmalloc(CHRRAMSIZE);
SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSize, 1); SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSIZE, 1);
AddExState(CHRRAM, CHRRAMSize, 0, "CHRR"); AddExState(CHRRAM, CHRRAMSIZE, 0, "CHRR");
AddExState(EXPREGS, 4, 0, "EXPR"); AddExState(EXPREGS, 4, 0, "EXPR");
} }
@ -906,10 +906,10 @@ static void M191CW(uint32 A, uint8 V) {
void Mapper191_Init(CartInfo *info) { void Mapper191_Init(CartInfo *info) {
GenMMC3_Init(info, 256, 256, 8, info->battery); GenMMC3_Init(info, 256, 256, 8, info->battery);
cwrap = M191CW; cwrap = M191CW;
CHRRAMSize = 2048; CHRRAMSIZE = 2048;
CHRRAM = (uint8*)FCEU_gmalloc(CHRRAMSize); CHRRAM = (uint8*)FCEU_gmalloc(CHRRAMSIZE);
SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSize, 1); SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSIZE, 1);
AddExState(CHRRAM, CHRRAMSize, 0, "CHRR"); AddExState(CHRRAM, CHRRAMSIZE, 0, "CHRR");
} }
// ---------------------------- Mapper 192 ------------------------------- // ---------------------------- Mapper 192 -------------------------------
@ -926,10 +926,10 @@ static void M192CW(uint32 A, uint8 V) {
void Mapper192_Init(CartInfo *info) { void Mapper192_Init(CartInfo *info) {
GenMMC3_Init(info, 512, 256, 8, info->battery); GenMMC3_Init(info, 512, 256, 8, info->battery);
cwrap = M192CW; cwrap = M192CW;
CHRRAMSize = 4096; CHRRAMSIZE = 4096;
CHRRAM = (uint8*)FCEU_gmalloc(CHRRAMSize); CHRRAM = (uint8*)FCEU_gmalloc(CHRRAMSIZE);
SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSize, 1); SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSIZE, 1);
AddExState(CHRRAM, CHRRAMSize, 0, "CHRR"); AddExState(CHRRAM, CHRRAMSIZE, 0, "CHRR");
} }
// ---------------------------- Mapper 194 ------------------------------- // ---------------------------- Mapper 194 -------------------------------
@ -944,16 +944,13 @@ static void M194CW(uint32 A, uint8 V) {
void Mapper194_Init(CartInfo *info) { void Mapper194_Init(CartInfo *info) {
GenMMC3_Init(info, 512, 256, 8, info->battery); GenMMC3_Init(info, 512, 256, 8, info->battery);
cwrap = M194CW; cwrap = M194CW;
CHRRAMSize = 2048; CHRRAMSIZE = 2048;
CHRRAM = (uint8*)FCEU_gmalloc(CHRRAMSize); CHRRAM = (uint8*)FCEU_gmalloc(CHRRAMSIZE);
SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSize, 1); SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSIZE, 1);
AddExState(CHRRAM, CHRRAMSize, 0, "CHRR"); AddExState(CHRRAM, CHRRAMSIZE, 0, "CHRR");
} }
// ---------------------------- Mapper 195 ------------------------------- // ---------------------------- Mapper 195 -------------------------------
static uint8 *wramtw;
static uint16 wramsize;
static void M195CW(uint32 A, uint8 V) { static void M195CW(uint32 A, uint8 V) {
if (V <= 3) // Crystalis (c).nes, Captain Tsubasa Vol 2 - Super Striker (C) if (V <= 3) // Crystalis (c).nes, Captain Tsubasa Vol 2 - Super Striker (C)
setchr1r(0x10, A, V); setchr1r(0x10, A, V);
@ -963,30 +960,19 @@ static void M195CW(uint32 A, uint8 V) {
static void M195Power(void) { static void M195Power(void) {
GenMMC3Power(); GenMMC3Power();
setprg4r(0x10, 0x5000, 0); setprg4r(0x10, 0x5000, 2);
SetWriteHandler(0x5000, 0x5fff, CartBW); SetWriteHandler(0x5000, 0x5fff, CartBW);
SetReadHandler(0x5000, 0x5fff, CartBR); SetReadHandler(0x5000, 0x5fff, CartBR);
} }
static void M195Close(void) {
if (wramtw)
FCEU_gfree(wramtw);
wramtw = NULL;
}
void Mapper195_Init(CartInfo *info) { void Mapper195_Init(CartInfo *info) {
GenMMC3_Init(info, 512, 256, 8, info->battery); GenMMC3_Init(info, 512, 256, 16, info->battery);
cwrap = M195CW; cwrap = M195CW;
info->Power = M195Power; info->Power = M195Power;
info->Close = M195Close; CHRRAMSIZE = 4096;
CHRRAMSize = 4096; CHRRAM = (uint8*)FCEU_gmalloc(CHRRAMSIZE);
CHRRAM = (uint8*)FCEU_gmalloc(CHRRAMSize); SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSIZE, 1);
SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSize, 1); AddExState(CHRRAM, CHRRAMSIZE, 0, "CHRR");
wramsize = 4096;
wramtw = (uint8*)FCEU_gmalloc(wramsize);
SetupCartPRGMapping(0x10, wramtw, wramsize, 1);
AddExState(CHRRAM, CHRRAMSize, 0, "CHRR");
AddExState(wramtw, wramsize, 0, "TRAM");
} }
// ---------------------------- Mapper 196 ------------------------------- // ---------------------------- Mapper 196 -------------------------------
@ -1065,14 +1051,9 @@ static void M198PW(uint32 A, uint8 V) {
} }
void Mapper198_Init(CartInfo *info) { void Mapper198_Init(CartInfo *info) {
GenMMC3_Init(info, 1024, 256, 8, info->battery); GenMMC3_Init(info, 1024, 0, 16, info->battery);
pwrap = M198PW; pwrap = M198PW;
info->Power = M195Power; info->Power = M195Power;
info->Close = M195Close;
wramsize = 4096;
wramtw = (uint8*)FCEU_gmalloc(wramsize);
SetupCartPRGMapping(0x10, wramtw, wramsize, 1);
AddExState(wramtw, wramsize, 0, "TRAM");
} }
// ---------------------------- Mapper 205 ------------------------------ // ---------------------------- Mapper 205 ------------------------------
@ -1292,9 +1273,9 @@ void TKSROM_Init(CartInfo *info) {
void TQROM_Init(CartInfo *info) { void TQROM_Init(CartInfo *info) {
GenMMC3_Init(info, 512, 64, 0, 0); GenMMC3_Init(info, 512, 64, 0, 0);
cwrap = TQWRAP; cwrap = TQWRAP;
CHRRAMSize = 8192; CHRRAMSIZE = 8192;
CHRRAM = (uint8*)FCEU_gmalloc(CHRRAMSize); CHRRAM = (uint8*)FCEU_gmalloc(CHRRAMSIZE);
SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSize, 1); SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSIZE, 1);
} }
void HKROM_Init(CartInfo *info) { void HKROM_Init(CartInfo *info) {

View File

@ -92,7 +92,7 @@ bool frameAdvanceLagSkip = false; //If this is true, frame advance will skip ove
bool AutoSS = false; //Flagged true when the first auto-savestate is made while a game is loaded, flagged false on game close bool AutoSS = false; //Flagged true when the first auto-savestate is made while a game is loaded, flagged false on game close
bool movieSubtitles = true; //Toggle for displaying movie subtitles bool movieSubtitles = true; //Toggle for displaying movie subtitles
bool DebuggerWasUpdated = false; //To prevent the debugger from updating things without being updated. bool DebuggerWasUpdated = false; //To prevent the debugger from updating things without being updated.
bool AutoResumePlay = true; // maybe this should be in "eoptions"... bool AutoResumePlay = false; // maybe this should be in "eoptions"...
char rom_name_when_closing_emulator[129] = {0}; char rom_name_when_closing_emulator[129] = {0};
FCEUGI::FCEUGI() FCEUGI::FCEUGI()

View File

@ -436,7 +436,7 @@ typedef struct {
//size //size
static int not_power2[] = static int not_power2[] =
{ {
228 198, 228
}; };
typedef struct { typedef struct {
char *name; char *name;
@ -463,7 +463,7 @@ static BMAPPINGLocal bmap[] = {
{"100-in-1", 15, Mapper15_Init}, {"100-in-1", 15, Mapper15_Init},
{"Bandai", 16, Mapper16_Init}, {"Bandai", 16, Mapper16_Init},
{"", 17, Mapper17_Init}, {"", 17, Mapper17_Init},
{"", 18, Mapper18_Init}, {"JALECO SS880006", 18, Mapper18_Init}, // JF-NNX (EB89018-30007) boards
{"Namcot 106", 19, Mapper19_Init}, {"Namcot 106", 19, Mapper19_Init},
// {"", 20, Mapper20_Init}, // {"", 20, Mapper20_Init},
{"Konami VRC2/VRC4 A", 21, Mapper21_Init}, {"Konami VRC2/VRC4 A", 21, Mapper21_Init},
@ -643,7 +643,7 @@ static BMAPPINGLocal bmap[] = {
{"TW MMC3+VRAM VER. D", 195, Mapper195_Init}, {"TW MMC3+VRAM VER. D", 195, Mapper195_Init},
{"", 196, Mapper196_Init}, {"", 196, Mapper196_Init},
{"", 197, Mapper197_Init}, {"", 197, Mapper197_Init},
{"", 198, Mapper198_Init}, {"TW MMC3+VRAM VER. E", 198, Mapper198_Init},
{"", 199, Mapper199_Init}, {"", 199, Mapper199_Init},
{"", 200, Mapper200_Init}, {"", 200, Mapper200_Init},
{"", 201, Mapper201_Init}, {"", 201, Mapper201_Init},
@ -748,6 +748,7 @@ int iNESLoad(const char *name, FCEUFILE *fp, int OverwriteVidMode) {
if ((ROM = (uint8*)FCEU_malloc(ROM_size << 14)) == NULL) if ((ROM = (uint8*)FCEU_malloc(ROM_size << 14)) == NULL)
return 0; return 0;
memset(ROM, 0xFF, ROM_size << 14);
if (VROM_size) { if (VROM_size) {
if ((VROM = (uint8*)FCEU_malloc(VROM_size << 13)) == NULL) { if ((VROM = (uint8*)FCEU_malloc(VROM_size << 13)) == NULL) {
@ -755,9 +756,9 @@ int iNESLoad(const char *name, FCEUFILE *fp, int OverwriteVidMode) {
ROM = NULL; ROM = NULL;
return 0; return 0;
} }
memset(VROM, 0xFF, VROM_size << 13);
} }
memset(ROM, 0xFF, ROM_size << 14);
if (VROM_size) memset(VROM, 0xFF, VROM_size << 13);
if (head.ROM_type & 4) { /* Trainer */ if (head.ROM_type & 4) { /* Trainer */
trainerpoo = (uint8*)FCEU_gmalloc(512); trainerpoo = (uint8*)FCEU_gmalloc(512);
FCEU_fread(trainerpoo, 512, 1, fp); FCEU_fread(trainerpoo, 512, 1, fp);
@ -766,12 +767,12 @@ int iNESLoad(const char *name, FCEUFILE *fp, int OverwriteVidMode) {
ResetCartMapping(); ResetCartMapping();
ResetExState(0, 0); ResetExState(0, 0);
SetupCartPRGMapping(0, ROM, ROM_size * 0x4000, 0); SetupCartPRGMapping(0, ROM, ROM_size << 14, 0);
FCEU_fread(ROM, 0x4000, (round) ? ROM_size : head.ROM_size, fp); FCEU_fread(ROM, 0x4000, (round) ? ROM_size : head.ROM_size, fp);
if (VROM_size) if (VROM_size)
FCEU_fread(VROM, 0x2000, head.VROM_size, fp); FCEU_fread(VROM, 0x2000, VROM_size, fp);
md5_starts(&md5); md5_starts(&md5);
md5_update(&md5, ROM, ROM_size << 14); md5_update(&md5, ROM, ROM_size << 14);