Update mapper 91

This commit is contained in:
negativeExponent
2020-02-16 01:10:28 +08:00
parent b7050cb55d
commit cfaee1217f

View File

@@ -2,6 +2,7 @@
* *
* Copyright notice for this file: * Copyright notice for this file:
* Copyright (C) 2012 CaH4e3 * Copyright (C) 2012 CaH4e3
* Copyright (C) 2020 negativeExponent
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@@ -18,10 +19,20 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
/* added 2020-2-15
* Street Fighter 3, Mortal Kombat II, Dragon Ball Z 2, Mario & Sonic 2 (JY-016)
* 1995 Super HIK 4-in-1 (JY-016), 1995 Super HiK 4-in-1 (JY-017)
* submapper 1 - Super Fighter III
* NOTE: nesdev's notes for IRQ is different that whats implemented here
*/
#include "mapinc.h" #include "mapinc.h"
static uint8 cregs[4], pregs[2]; static uint8 cregs[4], pregs[2];
static uint8 IRQCount, IRQa; static uint8 IRQCount, IRQa;
static uint8 submapper;
static uint8 outerbank;
static uint8 mirr;
static SFORMAT StateRegs[] = static SFORMAT StateRegs[] =
{ {
@@ -29,23 +40,36 @@ static SFORMAT StateRegs[] =
{ pregs, 2, "PREG" }, { pregs, 2, "PREG" },
{ &IRQa, 1, "IRQA" }, { &IRQa, 1, "IRQA" },
{ &IRQCount, 1, "IRQC" }, { &IRQCount, 1, "IRQC" },
{ &outerbank, 1, "BLOK" },
{ &mirr, 1, "MIRR" },
{ 0 } { 0 }
}; };
static void Sync(void) { static void Sync(void) {
setprg8(0x8000, pregs[0]); /* FCEU_printf("P0:%02x P1:%02x outerbank:%02x\n", pregs[0], pregs[1], outerbank);*/
setprg8(0xa000, pregs[1]); setprg8(0x8000, pregs[0] | (outerbank & 6) << 3);
setprg8(0xc000, ~1); setprg8(0xa000, pregs[1] | (outerbank & 6) << 3);
setprg8(0xe000, ~0); setprg8(0xc000, 0xE | (outerbank & 6) << 3);
setchr2(0x0000, cregs[0]); setprg8(0xe000, 0xF | (outerbank & 6) << 3);
setchr2(0x0800, cregs[1]); setchr2(0x0000, cregs[0] | (outerbank & 1) << 8);
setchr2(0x1000, cregs[2]); setchr2(0x0800, cregs[1] | (outerbank & 1) << 8);
setchr2(0x1800, cregs[3]); setchr2(0x1000, cregs[2] | (outerbank & 1) << 8);
setchr2(0x1800, cregs[3] | (outerbank & 1) << 8);
if (submapper == 1)
setmirror(mirr ^ 1);
} }
static DECLFW(M91Write0) { static DECLFW(M91Write0) {
cregs[A & 3] = V; switch (A & 7) {
Sync(); case 0:
case 1:
case 2:
case 3: cregs[A & 3] = V; Sync(); break;
case 4:
case 5: mirr = V & 1; Sync(); break;
default: /*FCEU_printf("A:%04x V:%02x\n", A, V);*/ break;
}
} }
static DECLFW(M91Write1) { static DECLFW(M91Write1) {
@@ -57,11 +81,17 @@ static DECLFW(M91Write1) {
} }
} }
static DECLFW(M91Write2) {
outerbank = A & 7;
Sync();
}
static void M91Power(void) { static void M91Power(void) {
Sync(); Sync();
SetReadHandler(0x8000, 0xffff, CartBR);
SetWriteHandler(0x6000, 0x6fff, M91Write0); SetWriteHandler(0x6000, 0x6fff, M91Write0);
SetWriteHandler(0x7000, 0x7fff, M91Write1); SetWriteHandler(0x7000, 0x7fff, M91Write1);
SetReadHandler(0x8000, 0xffff, CartBR); SetWriteHandler(0x8000, 0x9fff, M91Write2);
} }
static void M91IRQHook(void) { static void M91IRQHook(void) {
@@ -78,6 +108,12 @@ static void StateRestore(int version) {
} }
void Mapper91_Init(CartInfo *info) { void Mapper91_Init(CartInfo *info) {
submapper = 0;
if (info->CRC32 == 0x082778e6) /* Super Fighter III */
submapper = 1;
else if (info->iNES2)
submapper = info->submapper;
info->Power = M91Power; info->Power = M91Power;
GameHBIRQHook = M91IRQHook; GameHBIRQHook = M91IRQHook;
GameStateRestore = StateRestore; GameStateRestore = StateRestore;