From 8110346ccb9c47778fd5823272cb53bf4decd9c9 Mon Sep 17 00:00:00 2001 From: CaH4e3 Date: Tue, 18 Dec 2012 13:56:35 +0000 Subject: [PATCH] mapper 018 - fixed mapper 198 - fixed AutoResumePlay default option - "disabled" --- src/boards/18.cpp | 24 +++++++++- src/boards/mmc3.cpp | 113 ++++++++++++++++++-------------------------- src/fceu.cpp | 2 +- src/ines.cpp | 15 +++--- 4 files changed, 79 insertions(+), 75 deletions(-) diff --git a/src/boards/18.cpp b/src/boards/18.cpp index 0f3354e9..dcec0dc1 100644 --- a/src/boards/18.cpp +++ b/src/boards/18.cpp @@ -23,6 +23,8 @@ static uint8 preg[4], creg[8]; static uint8 IRQa, mirr; static int32 IRQCount, IRQLatch; +static uint8 *WRAM = NULL; +static uint32 WRAMSIZE; static SFORMAT StateRegs[] = { @@ -38,6 +40,7 @@ static SFORMAT StateRegs[] = static void Sync(void) { int i; for (i = 0; i < 8; i++) setchr1(i << 10, creg[i]); + setprg8r(0x10, 0x6000, 0); setprg8(0x8000, preg[0]); setprg8(0xA000, preg[1]); setprg8(0xC000, preg[2]); @@ -75,12 +78,14 @@ static DECLFW(M18WriteChr) { } static void M18Power(void) { + IRQa = 0; preg[0] = 0; preg[1] = 1; preg[2] = ~1; preg[3] = ~0; Sync(); - SetReadHandler(0x8000, 0xFFFF, CartBR); + SetReadHandler(0x6000, 0xFFFF, CartBR); + SetWriteHandler(0x6000, 0x7FFF, CartBW); SetWriteHandler(0x8000, 0x9FFF, M18WritePrg); SetWriteHandler(0xA000, 0xDFFF, M18WriteChr); 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) { Sync(); } void Mapper18_Init(CartInfo *info) { info->Power = M18Power; + info->Close = M18Close; MapIRQHook = M18IRQHook; 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); } diff --git a/src/boards/mmc3.cpp b/src/boards/mmc3.cpp index 0b0c4d5b..5310e0bb 100644 --- a/src/boards/mmc3.cpp +++ b/src/boards/mmc3.cpp @@ -21,7 +21,7 @@ */ /* Code for emulating iNES mappers 4,12,44,45,47,49,52,74,114,115,116,118, - 119,165,205,245,249,250,254 + 119,165,205,245,249,250,254 */ #include "mapinc.h" @@ -29,8 +29,9 @@ uint8 MMC3_cmd; uint8 *WRAM; +uint32 WRAMSIZE; uint8 *CHRRAM; -uint32 CHRRAMSize; +uint32 CHRRAMSIZE; uint8 DRegBuf[8]; uint8 EXPREGS[8]; /* For bootleg games, mostly. */ uint8 A000B, A001B; @@ -55,7 +56,6 @@ static SFORMAT MMC3_StateRegs[] = { 0 } }; -static int wrams; static int isRevB = 1; void (*pwrap)(uint32 A, uint8 V); @@ -249,22 +249,22 @@ void GenMMC3Power(void) { A001B = A000B = 0; setmirror(1); if (mmc3opts & 1) { - if (wrams == 1024) { + if (WRAMSIZE == 1024) { FCEU_CheatAddRAM(1, 0x7000, WRAM); SetReadHandler(0x7000, 0x7FFF, MAWRAMMMC6); SetWriteHandler(0x7000, 0x7FFF, MBWRAMMMC6); } else { - FCEU_CheatAddRAM((wrams & 0x1fff) >> 10, 0x6000, WRAM); - SetWriteHandler(0x6000, 0x6000 + ((wrams - 1) & 0x1fff), CartBW); - SetReadHandler(0x6000, 0x6000 + ((wrams - 1) & 0x1fff), CartBR); + FCEU_CheatAddRAM((WRAMSIZE & 0x1fff) >> 10, 0x6000, WRAM); + SetWriteHandler(0x6000, 0x6000 + ((WRAMSIZE - 1) & 0x1fff), CartBW); + SetReadHandler(0x6000, 0x6000 + ((WRAMSIZE - 1) & 0x1fff), CartBR); setprg8r(0x10, 0x6000, 0); } if (!(mmc3opts & 2)) - FCEU_dwmemset(WRAM, 0, wrams); + FCEU_dwmemset(WRAM, 0, WRAMSIZE); } MMC3RegReset(); if (CHRRAM) - FCEU_dwmemset(CHRRAM, 0, CHRRAMSize); + FCEU_dwmemset(CHRRAM, 0, CHRRAMSIZE); } static void GenMMC3Close(void) { @@ -280,7 +280,7 @@ void GenMMC3_Init(CartInfo *info, int prg, int chr, int wram, int battery) { cwrap = GENCWRAP; mwrap = GENMWRAP; - wrams = wram << 10; + WRAMSIZE = wram << 10; PRGmask8[0] &= (prg >> 13) - 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) { mmc3opts |= 1; - WRAM = (uint8*)FCEU_gmalloc(wrams); - SetupCartPRGMapping(0x10, WRAM, wrams, 1); - AddExState(WRAM, wrams, 0, "MRAM"); + WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE); + SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1); + AddExState(WRAM, WRAMSIZE, 0, "WRAM"); } if (battery) { mmc3opts |= 2; info->SaveGame[0] = WRAM; - info->SaveGameLen[0] = wrams; + info->SaveGameLen[0] = WRAMSIZE; } AddExState(MMC3_StateRegs, ~0, 0, 0); @@ -668,10 +668,10 @@ static void M74CW(uint32 A, uint8 V) { void Mapper74_Init(CartInfo *info) { GenMMC3_Init(info, 512, 256, 8, info->battery); cwrap = M74CW; - CHRRAMSize = 2048; - CHRRAM = (uint8*)FCEU_gmalloc(CHRRAMSize); - SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSize, 1); - AddExState(CHRRAM, CHRRAMSize, 0, "CHRR"); + CHRRAMSIZE = 2048; + CHRRAM = (uint8*)FCEU_gmalloc(CHRRAMSIZE); + SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSIZE, 1); + AddExState(CHRRAM, CHRRAMSIZE, 0, "CHRR"); } // ---------------------------- Mapper 114 ------------------------------ @@ -799,9 +799,9 @@ static void TQWRAP(uint32 A, uint8 V) { void Mapper119_Init(CartInfo *info) { GenMMC3_Init(info, 512, 64, 0, 0); cwrap = TQWRAP; - CHRRAMSize = 8192; - CHRRAM = (uint8*)FCEU_gmalloc(CHRRAMSize); - SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSize, 1); + CHRRAMSIZE = 8192; + CHRRAM = (uint8*)FCEU_gmalloc(CHRRAMSIZE); + SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSIZE, 1); } // ---------------------------- Mapper 134 ------------------------------ @@ -890,10 +890,10 @@ void Mapper165_Init(CartInfo *info) { cwrap = M165CWM; PPU_hook = M165PPU; info->Power = M165Power; - CHRRAMSize = 4096; - CHRRAM = (uint8*)FCEU_gmalloc(CHRRAMSize); - SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSize, 1); - AddExState(CHRRAM, CHRRAMSize, 0, "CHRR"); + CHRRAMSIZE = 4096; + CHRRAM = (uint8*)FCEU_gmalloc(CHRRAMSIZE); + SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSIZE, 1); + AddExState(CHRRAM, CHRRAMSIZE, 0, "CHRR"); AddExState(EXPREGS, 4, 0, "EXPR"); } @@ -906,10 +906,10 @@ static void M191CW(uint32 A, uint8 V) { void Mapper191_Init(CartInfo *info) { GenMMC3_Init(info, 256, 256, 8, info->battery); cwrap = M191CW; - CHRRAMSize = 2048; - CHRRAM = (uint8*)FCEU_gmalloc(CHRRAMSize); - SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSize, 1); - AddExState(CHRRAM, CHRRAMSize, 0, "CHRR"); + CHRRAMSIZE = 2048; + CHRRAM = (uint8*)FCEU_gmalloc(CHRRAMSIZE); + SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSIZE, 1); + AddExState(CHRRAM, CHRRAMSIZE, 0, "CHRR"); } // ---------------------------- Mapper 192 ------------------------------- @@ -926,10 +926,10 @@ static void M192CW(uint32 A, uint8 V) { void Mapper192_Init(CartInfo *info) { GenMMC3_Init(info, 512, 256, 8, info->battery); cwrap = M192CW; - CHRRAMSize = 4096; - CHRRAM = (uint8*)FCEU_gmalloc(CHRRAMSize); - SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSize, 1); - AddExState(CHRRAM, CHRRAMSize, 0, "CHRR"); + CHRRAMSIZE = 4096; + CHRRAM = (uint8*)FCEU_gmalloc(CHRRAMSIZE); + SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSIZE, 1); + AddExState(CHRRAM, CHRRAMSIZE, 0, "CHRR"); } // ---------------------------- Mapper 194 ------------------------------- @@ -944,16 +944,13 @@ static void M194CW(uint32 A, uint8 V) { void Mapper194_Init(CartInfo *info) { GenMMC3_Init(info, 512, 256, 8, info->battery); cwrap = M194CW; - CHRRAMSize = 2048; - CHRRAM = (uint8*)FCEU_gmalloc(CHRRAMSize); - SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSize, 1); - AddExState(CHRRAM, CHRRAMSize, 0, "CHRR"); + CHRRAMSIZE = 2048; + CHRRAM = (uint8*)FCEU_gmalloc(CHRRAMSIZE); + SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSIZE, 1); + AddExState(CHRRAM, CHRRAMSIZE, 0, "CHRR"); } // ---------------------------- Mapper 195 ------------------------------- -static uint8 *wramtw; -static uint16 wramsize; - static void M195CW(uint32 A, uint8 V) { if (V <= 3) // Crystalis (c).nes, Captain Tsubasa Vol 2 - Super Striker (C) setchr1r(0x10, A, V); @@ -963,30 +960,19 @@ static void M195CW(uint32 A, uint8 V) { static void M195Power(void) { GenMMC3Power(); - setprg4r(0x10, 0x5000, 0); + setprg4r(0x10, 0x5000, 2); SetWriteHandler(0x5000, 0x5fff, CartBW); SetReadHandler(0x5000, 0x5fff, CartBR); } -static void M195Close(void) { - if (wramtw) - FCEU_gfree(wramtw); - wramtw = NULL; -} - void Mapper195_Init(CartInfo *info) { - GenMMC3_Init(info, 512, 256, 8, info->battery); + GenMMC3_Init(info, 512, 256, 16, info->battery); cwrap = M195CW; info->Power = M195Power; - info->Close = M195Close; - CHRRAMSize = 4096; - CHRRAM = (uint8*)FCEU_gmalloc(CHRRAMSize); - SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSize, 1); - wramsize = 4096; - wramtw = (uint8*)FCEU_gmalloc(wramsize); - SetupCartPRGMapping(0x10, wramtw, wramsize, 1); - AddExState(CHRRAM, CHRRAMSize, 0, "CHRR"); - AddExState(wramtw, wramsize, 0, "TRAM"); + CHRRAMSIZE = 4096; + CHRRAM = (uint8*)FCEU_gmalloc(CHRRAMSIZE); + SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSIZE, 1); + AddExState(CHRRAM, CHRRAMSIZE, 0, "CHRR"); } // ---------------------------- Mapper 196 ------------------------------- @@ -1065,14 +1051,9 @@ static void M198PW(uint32 A, uint8 V) { } void Mapper198_Init(CartInfo *info) { - GenMMC3_Init(info, 1024, 256, 8, info->battery); + GenMMC3_Init(info, 1024, 0, 16, info->battery); pwrap = M198PW; 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 ------------------------------ @@ -1292,9 +1273,9 @@ void TKSROM_Init(CartInfo *info) { void TQROM_Init(CartInfo *info) { GenMMC3_Init(info, 512, 64, 0, 0); cwrap = TQWRAP; - CHRRAMSize = 8192; - CHRRAM = (uint8*)FCEU_gmalloc(CHRRAMSize); - SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSize, 1); + CHRRAMSIZE = 8192; + CHRRAM = (uint8*)FCEU_gmalloc(CHRRAMSIZE); + SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSIZE, 1); } void HKROM_Init(CartInfo *info) { diff --git a/src/fceu.cpp b/src/fceu.cpp index ff12f63d..3369273b 100644 --- a/src/fceu.cpp +++ b/src/fceu.cpp @@ -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 movieSubtitles = true; //Toggle for displaying movie subtitles 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}; FCEUGI::FCEUGI() diff --git a/src/ines.cpp b/src/ines.cpp index e9435a21..76d90bc6 100644 --- a/src/ines.cpp +++ b/src/ines.cpp @@ -436,7 +436,7 @@ typedef struct { //size static int not_power2[] = { - 228 + 198, 228 }; typedef struct { char *name; @@ -463,7 +463,7 @@ static BMAPPINGLocal bmap[] = { {"100-in-1", 15, Mapper15_Init}, {"Bandai", 16, Mapper16_Init}, {"", 17, Mapper17_Init}, - {"", 18, Mapper18_Init}, + {"JALECO SS880006", 18, Mapper18_Init}, // JF-NNX (EB89018-30007) boards {"Namcot 106", 19, Mapper19_Init}, // {"", 20, Mapper20_Init}, {"Konami VRC2/VRC4 A", 21, Mapper21_Init}, @@ -643,7 +643,7 @@ static BMAPPINGLocal bmap[] = { {"TW MMC3+VRAM VER. D", 195, Mapper195_Init}, {"", 196, Mapper196_Init}, {"", 197, Mapper197_Init}, - {"", 198, Mapper198_Init}, + {"TW MMC3+VRAM VER. E", 198, Mapper198_Init}, {"", 199, Mapper199_Init}, {"", 200, Mapper200_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) return 0; + memset(ROM, 0xFF, ROM_size << 14); if (VROM_size) { if ((VROM = (uint8*)FCEU_malloc(VROM_size << 13)) == NULL) { @@ -755,9 +756,9 @@ int iNESLoad(const char *name, FCEUFILE *fp, int OverwriteVidMode) { ROM = NULL; 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 */ trainerpoo = (uint8*)FCEU_gmalloc(512); FCEU_fread(trainerpoo, 512, 1, fp); @@ -766,12 +767,12 @@ int iNESLoad(const char *name, FCEUFILE *fp, int OverwriteVidMode) { ResetCartMapping(); 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); if (VROM_size) - FCEU_fread(VROM, 0x2000, head.VROM_size, fp); + FCEU_fread(VROM, 0x2000, VROM_size, fp); md5_starts(&md5); md5_update(&md5, ROM, ROM_size << 14);