BMC-830425C-4391T: Update cpu banking
- Fixes loading Mermaid game.
This commit is contained in:
@@ -26,66 +26,46 @@
|
||||
|
||||
#include "mapinc.h"
|
||||
|
||||
static uint8 regs[2];
|
||||
static uint8 isMermaid = 0;
|
||||
static uint8 bank_size;
|
||||
static uint8 inner_bank;
|
||||
static uint8 outer_bank;
|
||||
|
||||
static SFORMAT StateRegs[] =
|
||||
{
|
||||
{ regs, 2, "REGS" },
|
||||
{ &isMermaid, 1, "MERM" },
|
||||
{ &inner_bank, 1, "INNB" },
|
||||
{ &outer_bank, 1, "OUTB" },
|
||||
{ &bank_size, 1, "SIZE" },
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
static void Sync(void) {
|
||||
uint8 bank_size = (regs[0] & 0x80) ? 0x07: 0x0F;
|
||||
uint8 outer_bank = !isMermaid ? (regs[0] & 0x78) : 0x04;
|
||||
uint8 inner_bank = regs[1];
|
||||
uint8 game_block = regs[0] & 0x78;
|
||||
|
||||
/* TODO: Hacky and forced mapping of outer banks(game block)... */
|
||||
if (!isMermaid) {
|
||||
switch(game_block) {
|
||||
case 0x00: /* botb outerbank=0 */
|
||||
case 0x10: /* rocketeer outerbank=1 */
|
||||
case 0x20: /* contra outerbank=2 */
|
||||
case 0x28: /* ducktales outerbank=3 */
|
||||
case 0x38: /* school fight outerbank=5 */
|
||||
outer_bank = (game_block >> 4) + ((game_block & 0x08) ? 0x01 : 0x00);
|
||||
outer_bank |= (game_block >> 3) & 1;
|
||||
break;
|
||||
case 0x30:
|
||||
/* Mermaid game block is tricky (to me at least). Aim here is
|
||||
* when this register is selected, ignore any other outer bank reg changes */
|
||||
isMermaid = 1;
|
||||
outer_bank = 0x04;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
setprg16r(outer_bank, 0x8000, (inner_bank & bank_size));
|
||||
setprg16r(outer_bank, 0xC000, bank_size);
|
||||
setchr8(0);
|
||||
}
|
||||
|
||||
static DECLFW(M320Write) {
|
||||
if ((A & 0xF0E0) == 0xF0E0) {
|
||||
regs[0] = (A & 0x1F) << 3;
|
||||
const uint8 chip[] = { 0, 0, 1, 0, 2, 3, 4, 5 };
|
||||
/* address mask is inconsistent with that is in the wiki. Mask should be
|
||||
* 0xFFE0 or Mermaid game will not work. */
|
||||
if ((A & 0xFFE0) == 0xF0E0) {
|
||||
outer_bank = chip[(A & 0x0F)];
|
||||
bank_size = (A & 0x10) ? 0x07 : 0x0F;
|
||||
}
|
||||
regs[1] = V & 0x0F;
|
||||
inner_bank = (V & 0x0F);
|
||||
Sync();
|
||||
}
|
||||
|
||||
static void M320Power(void) {
|
||||
regs[0] = regs[1] = 0;
|
||||
isMermaid = 0;
|
||||
bank_size = 0x0F;
|
||||
Sync();
|
||||
SetReadHandler(0x8000, 0xFFFF, CartBR);
|
||||
SetWriteHandler(0x8000, 0xFFFF, M320Write);
|
||||
}
|
||||
|
||||
static void M320Reset(void) {
|
||||
regs[0] = regs[1] = 0;
|
||||
isMermaid = 0;
|
||||
inner_bank = outer_bank = 0;
|
||||
bank_size = 0x0F;
|
||||
Sync();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user