Mapper57: fix mirroring

This commit is contained in:
retro-wertz
2017-10-17 11:57:21 +08:00
parent 52bfae1ab4
commit 3d4765ad74

View File

@@ -21,47 +21,42 @@
#include "mapinc.h" #include "mapinc.h"
static uint8 prg_reg; static uint8 regs[2];
static uint8 chr_reg;
static uint8 hrd_flag; static uint8 hrd_flag;
static SFORMAT StateRegs[] = static SFORMAT StateRegs[] =
{ {
{ &hrd_flag, 1, "DPSW" }, { &hrd_flag, 1, "DPSW" },
{ &prg_reg, 1, "PRG" }, { regs, 2, "REGS" },
{ &chr_reg, 1, "CHR" },
{ 0 } { 0 }
}; };
static void Sync(void) { static void Sync(void) {
if (prg_reg & 0x10) if (regs[1] & 0x10)
setprg32(0x8000, (prg_reg >> 6) & 3); setprg32(0x8000, (regs[1] >> 6) & 3);
else { else {
setprg16(0x8000, (prg_reg >> 5) & 7); setprg16(0x8000, (regs[1] >> 5) & 7);
setprg16(0xC000, (prg_reg >> 5) & 7); setprg16(0xC000, (regs[1] >> 5) & 7);
} }
/* Mirroring (0=Vert, 1=Horz) setmirror((regs[1] & 8) >> 3 ^ 1);
* https://wiki.nesdev.com/w/index.php/INES_Mapper_057 setchr8((regs[0] & 7) | (regs[1] & 7) | ((regs[0] & 0x40) >> 3));
*/
setmirror((prg_reg & 8) ? MI_H : MI_V);
setchr8((chr_reg & 7) | (prg_reg & 7) | ((chr_reg & 0x40) >> 3));
} }
#if 0
static DECLFR(M57Read) { static DECLFR(M57Read) {
return hrd_flag; return hrd_flag;
} }
#endif
static DECLFW(M57Write) { static DECLFW(M57Write) {
if ((A & 0x8800) == 0x8800) switch (A & 0x8800) {
prg_reg = V; case 0x8000: regs[0] = V; Sync(); break;
else case 0x8800: regs[1] = V; Sync(); break;
chr_reg = V; }
Sync();
} }
static void M57Power(void) { static void M57Power(void) {
prg_reg = 0; regs[1] = regs[0] = 0;
chr_reg = 0;
hrd_flag = 0; hrd_flag = 0;
SetReadHandler(0x8000, 0xFFFF, CartBR); SetReadHandler(0x8000, 0xFFFF, CartBR);
SetWriteHandler(0x8000, 0xFFFF, M57Write); SetWriteHandler(0x8000, 0xFFFF, M57Write);