Mapper 289: Support Super 76-in-1 Contra

This commit is contained in:
NewRisingSun
2022-03-01 17:33:39 +01:00
parent 7a9a044d22
commit 95b79c4745

View File

@@ -24,79 +24,51 @@
#include "mapinc.h" #include "mapinc.h"
static uint8 inner_bank, outer_bank, mode; static uint8 latch, reg[2];
static SFORMAT StateRegs[] = static SFORMAT StateRegs[] =
{ {
{ &inner_bank, 1, "INB0" }, { &latch, 1, "LATC" },
{ &outer_bank, 1, "OUTB" }, { reg, 2, "REGS" },
{ &mode, 1, "MODE" },
{ 0 } { 0 }
}; };
static void Sync(void) { static void Sync(void) {
uint8 bbank = (mode & 4) ? 0 : (inner_bank & 7); if (reg[0] &2) { /* UNROM */
uint8 bank = outer_bank | bbank; setprg16(0x8000, latch &7 | reg[1] &~7);
uint8 preg[2]; setprg16(0xC000, 7 | reg[1] &~7);
} else
/* 0: NROM-128: Same inner/outer 16 KiB bank at CPU $8000-$BFFF if (reg[0] &1) /* NROM-256 */
* and $C000-$FFFF setprg32(0x8000, reg[1] >>1);
* 1: NROM-256: 32 kiB bank at CPU $8000-$FFFF (Selected inner/outer bank SHR 1) else { /* NROM-128 */
* 2: UNROM: Inner/outer bank at CPU $8000-BFFF, setprg16(0x8000, reg[1]);
* fixed inner bank 7 within outer bank at $C000-$FFFF setprg16(0xC000, reg[1]);
* 3: Unknown
*
* The combined inner/outer bank is simply the inner bank, selected by the
* latch at $8000-$FFFF (or 0 if the latch is disabled) ORed with the
* outer bank selected by $6001, without any bit shifting.
*/
preg[0] = bank;
preg[1] = 0;
switch (mode & 3) {
case 0x00:
case 0x01:
preg[1] = bank | ((mode & 1) ? 1 : 0);
break;
case 0x02:
preg[1] = outer_bank | 7;
case 0x03:
break;
} }
SetupCartCHRMapping(0, CHRptr[0], 0x2000, !(reg[0] &4)); /* CHR-RAM write-protect */
setchr8(0); setchr8(0);
setprg16(0x8000, preg[0]); setmirror(!(reg[0] &8));
setprg16(0xC000, preg[1]);
setmirror(((mode & 8) >> 3) ^ 1);
} }
static DECLFW(Write0) { static DECLFW(WriteReg) {
mode = V; reg[A &1] =V;
Sync(); Sync();
} }
static DECLFW(Write1) { static DECLFW(WriteLatch) {
outer_bank = V; latch = V;
Sync();
}
static DECLFW(Write8) {
inner_bank = V;
Sync(); Sync();
} }
static void BMC60311CPower(void) { static void BMC60311CPower(void) {
inner_bank = outer_bank = mode = 0; latch =reg[0] =reg[1] =0;
Sync(); Sync();
SetReadHandler(0x8000, 0xFFFF, CartBR); SetReadHandler(0x8000, 0xFFFF, CartBR);
SetWriteHandler(0x6000, 0x6000, Write0); SetWriteHandler(0x6000, 0x6001, WriteReg);
SetWriteHandler(0x6001, 0x6001, Write1); SetWriteHandler(0x8000, 0xFFFF, WriteLatch);
SetWriteHandler(0x8000, 0xFFFF, Write8);
} }
static void BMC60311CReset(void) { static void BMC60311CReset(void) {
inner_bank = outer_bank = mode = 0; latch =reg[0] =reg[1] =0;
Sync(); Sync();
} }