From 86d3ef51710dc333d2299da1f46a4dbe1380eb44 Mon Sep 17 00:00:00 2001 From: Oggom Date: Thu, 18 Jun 2015 16:41:53 +0200 Subject: [PATCH] Backport r167 and r168 - mapper 35 fixes --- src/boards/sc-127.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/boards/sc-127.c b/src/boards/sc-127.c index c092510..2d2d968 100644 --- a/src/boards/sc-127.c +++ b/src/boards/sc-127.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * Wario Land II (Kirby hack) VRC4 + * Wario Land II (Kirby hack) */ #include "mapinc.h" @@ -31,16 +31,18 @@ static SFORMAT StateRegs[] = { { reg, 8, "REGS" }, { chr, 8, "CHRS" }, - { &IRQCount, 16, "IRQc" }, - { &IRQa, 16, "IRQa" }, + { &IRQCount, 2, "IRQc" }, + { &IRQa, 2, "IRQa" }, { 0 } }; static void Sync(void) { int i; + setprg8r(0x10, 0x6000, 0); setprg8(0x8000, reg[0]); setprg8(0xA000, reg[1]); setprg8(0xC000, reg[2]); + setprg8(0xE000, ~0); for (i = 0; i < 8; i++) setchr1(i << 10, chr[i]); setmirror(reg[3] ^ 1); @@ -67,20 +69,26 @@ static DECLFW(UNLSC127Write) { Sync(); } +static DECLFR(UNLSC127ProtRead) { + return 0x20; +} + static void UNLSC127Power(void) { + IRQCount = IRQa = 0; Sync(); - setprg8r(0x10, 0x6000, 0); - setprg8(0xE000, ~0); + SetReadHandler(0x5800, 0x5800, UNLSC127ProtRead); SetReadHandler(0x6000, 0x7fff, CartBR); SetWriteHandler(0x6000, 0x7fff, CartBW); SetReadHandler(0x8000, 0xFFFF, CartBR); SetWriteHandler(0x8000, 0xFFFF, UNLSC127Write); + FCEU_CheatAddRAM(WRAMSIZE >> 10, 0x6000, WRAM); } static void UNLSC127IRQ(void) { if (IRQa) { - IRQCount--; - if (IRQCount == 0) { + if(IRQCount > 0) + IRQCount--; + if (!IRQCount) { X6502_IRQBegin(FCEU_IQEXT); IRQa = 0; } @@ -88,6 +96,7 @@ static void UNLSC127IRQ(void) { } static void UNLSC127Reset(void) { + IRQCount = IRQa = 0; } static void UNLSC127Close(void) {