BMC-K-3036: Fix incorrect write address range

This commit is contained in:
retro-wertz
2019-06-26 22:14:48 +08:00
parent 6653f4028a
commit 6d26ce4f9f
3 changed files with 16 additions and 12 deletions

View File

@@ -26,40 +26,44 @@
#include "mapinc.h" #include "mapinc.h"
static uint8 regs[2]; static uint8 regs[2], mirr, mode;
static SFORMAT StateRegs[] = static SFORMAT StateRegs[] =
{ {
{ regs, 2, "REGS" }, { regs, 2, "REGS" },
{ &mode, 1, "MODE" },
{ &mirr, 1, "MIRR" },
{ 0 } { 0 }
}; };
static void Sync(void) { static void Sync(void) {
if (regs[0] & 0x20) { /* NROM-128 */ if (mode) { /* NROM-128 */
setprg16(0x8000, regs[0] & 0x1F); setprg16(0x8000, regs[0]);
setprg16(0xC000, regs[0] & 0x1F); setprg16(0xC000, regs[0]);
} else { /* UNROM */ } else { /* UNROM */
setprg16(0x8000, (regs[0] & 0x1F) | (regs[1] & 0x07)); setprg16(0x8000, regs[0] | regs[1]);
setprg16(0xC000, (regs[0] & 0x1F) | 0x07); setprg16(0xC000, regs[0] | 0x07);
} }
setchr8(0); setchr8(0);
setmirror(((regs[0] & 0x25) == 0x25) ? MI_H : MI_V); setmirror(mirr);
} }
static DECLFW(M340Write) { static DECLFW(M340Write) {
regs[0] = A & 0xFF; regs[0] = A & 0x1F;
regs[1] = V & 0xFF; regs[1] = V & 0x07;
mode = A & 0x20;
mirr = ((A & 0x25) == 0x25) ? 0 : 1;
Sync(); Sync();
} }
static void BMCK3036Power(void) { static void BMCK3036Power(void) {
Sync(); Sync();
SetReadHandler(0x8000, 0xFFFF, CartBR); SetReadHandler(0x8000, 0xFFFF, CartBR);
SetWriteHandler(0x8000, 0xBFFF, M340Write); SetWriteHandler(0x8000, 0xFFFF, M340Write);
} }
static void BMCK3036Reset(void) { static void BMCK3036Reset(void) {
regs[0] = regs[1] = 0; regs[0] = regs[1] = mode = mirr = 0;
Sync(); Sync();
} }