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"
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);