From 3d4765ad74b4b14127d5c56355a9563cdae7333b Mon Sep 17 00:00:00 2001 From: retro-wertz Date: Tue, 17 Oct 2017 11:57:21 +0800 Subject: [PATCH] Mapper57: fix mirroring --- src/boards/57.c | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/src/boards/57.c b/src/boards/57.c index bb93c37..df79d44 100644 --- a/src/boards/57.c +++ b/src/boards/57.c @@ -21,47 +21,42 @@ #include "mapinc.h" -static uint8 prg_reg; -static uint8 chr_reg; +static uint8 regs[2]; static uint8 hrd_flag; static SFORMAT StateRegs[] = { { &hrd_flag, 1, "DPSW" }, - { &prg_reg, 1, "PRG" }, - { &chr_reg, 1, "CHR" }, + { regs, 2, "REGS" }, { 0 } }; static void Sync(void) { - if (prg_reg & 0x10) - setprg32(0x8000, (prg_reg >> 6) & 3); + if (regs[1] & 0x10) + setprg32(0x8000, (regs[1] >> 6) & 3); else { - setprg16(0x8000, (prg_reg >> 5) & 7); - setprg16(0xC000, (prg_reg >> 5) & 7); + setprg16(0x8000, (regs[1] >> 5) & 7); + setprg16(0xC000, (regs[1] >> 5) & 7); } - /* Mirroring (0=Vert, 1=Horz) - * https://wiki.nesdev.com/w/index.php/INES_Mapper_057 - */ - setmirror((prg_reg & 8) ? MI_H : MI_V); - setchr8((chr_reg & 7) | (prg_reg & 7) | ((chr_reg & 0x40) >> 3)); + setmirror((regs[1] & 8) >> 3 ^ 1); + setchr8((regs[0] & 7) | (regs[1] & 7) | ((regs[0] & 0x40) >> 3)); } +#if 0 static DECLFR(M57Read) { return hrd_flag; } +#endif static DECLFW(M57Write) { - if ((A & 0x8800) == 0x8800) - prg_reg = V; - else - chr_reg = V; - Sync(); + switch (A & 0x8800) { + case 0x8000: regs[0] = V; Sync(); break; + case 0x8800: regs[1] = V; Sync(); break; + } } static void M57Power(void) { - prg_reg = 0; - chr_reg = 0; + regs[1] = regs[0] = 0; hrd_flag = 0; SetReadHandler(0x8000, 0xFFFF, CartBR); SetWriteHandler(0x8000, 0xFFFF, M57Write);