Mapper 195: Reimplemented according to nesdev description. This makes the emulaton compatible with unhacked Captain Tsubasa 2, and IN-compatible with hacked Captain Tsubasa 2.

This commit is contained in:
NewRisingSun
2022-12-30 00:43:48 +01:00
parent a99b4b11bd
commit 2b172d3eb2
2 changed files with 96 additions and 26 deletions

88
src/boards/195.c Normal file
View File

@@ -0,0 +1,88 @@
/* FCEUmm - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2022
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "mapinc.h"
#include "mmc3.h"
writefunc writePPU;
static uint8 *CHRRAM;
static uint32 CHRRAMSIZE;
static uint8 mask;
static uint8 compare;
extern uint32 RefreshAddr;
static void Mapper195_CHRWrap(uint32 A, uint8 V) {
if ((V &mask) ==compare)
setchr1r(0x10, A, V);
else
setchr1r(0, A, V);
}
static const uint8 compares[8] = { 0x28, 0x00, 0x4C, 0x64, 0x46, 0x7C, 0x04, 0xFF };
static DECLFW(Mapper195_InterceptPPUWrite) {
if (RefreshAddr <0x2000) {
int addr =RefreshAddr;
int reg, bank;
if (MMC3_cmd &0x80) addr ^=0x1000;
if (addr <0x1000)
reg =addr >>11;
else
reg =(addr >>10) -2;
bank =DRegBuf[reg];
if (bank &0x80) {
if (bank &0x10) {
mask =0x00;
compare =0xFF;
} else {
int index =(bank &0x02? 1: 0) | (bank &0x08? 2: 0) | (bank &0x40? 4: 0);
mask =bank &0x40? 0xFE: 0xFC;
compare =compares[index];
}
FixMMC3CHR(MMC3_cmd);
}
}
writePPU(A, V);
}
static void Mapper195_Power(void) {
mask =0xFC;
compare =0x00;
GenMMC3Power();
setprg4r(0x10, 0x5000, 2);
SetWriteHandler(0x5000, 0x5FFF, CartBW);
SetReadHandler(0x5000, 0x5FFF, CartBR);
if (GetWriteHandler(0x2007) !=Mapper195_InterceptPPUWrite) {
writePPU =GetWriteHandler(0x2007);
SetWriteHandler(0x2007, 0x2007, Mapper195_InterceptPPUWrite);
}
}
void Mapper195_Init(CartInfo *info) {
GenMMC3_Init(info, 512, 256, 16, info->battery);
cwrap = Mapper195_CHRWrap;
info->Power = Mapper195_Power;
info->Reset = MMC3RegReset;
CHRRAMSIZE =4096;
CHRRAM =(uint8*)FCEU_gmalloc(CHRRAMSIZE);
SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSIZE, 1);
AddExState(CHRRAM, CHRRAMSIZE, 0, "CHRR");
}

View File

@@ -1007,31 +1007,6 @@ void Mapper194_Init(CartInfo *info) {
AddExState(CHRRAM, CHRRAMSIZE, 0, "CHRR");
}
/* ---------------------------- Mapper 195 ------------------------------- */
static void M195CW(uint32 A, uint8 V) {
if (V <= 3) /* Crystalis (c).nes, Captain Tsubasa Vol 2 - Super Striker (C) */
setchr1r(0x10, A, V);
else
setchr1r(0, A, V);
}
static void M195Power(void) {
GenMMC3Power();
setprg4r(0x10, 0x5000, 2);
SetWriteHandler(0x5000, 0x5fff, CartBW);
SetReadHandler(0x5000, 0x5fff, CartBR);
}
void Mapper195_Init(CartInfo *info) {
GenMMC3_Init(info, 512, 256, 16, info->battery);
cwrap = M195CW;
info->Power = M195Power;
CHRRAMSIZE = 4096;
CHRRAM = (uint8*)FCEU_gmalloc(CHRRAMSIZE);
SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSIZE, 1);
AddExState(CHRRAM, CHRRAMSIZE, 0, "CHRR");
}
/* ---------------------------- Mapper 196 ------------------------------- */
/* MMC3 board with optional command address line connection, allows to
* make three-four different wirings to IRQ address lines and separately to
@@ -1127,6 +1102,13 @@ void Mapper197_Init(CartInfo *info) {
/* ---------------------------- Mapper 198 ------------------------------- */
static void M198Power(void) {
GenMMC3Power();
setprg4r(0x10, 0x5000, 2);
SetWriteHandler(0x5000, 0x5fff, CartBW);
SetReadHandler(0x5000, 0x5fff, CartBR);
}
static void M198PW(uint32 A, uint8 V) {
if (V >= 0x50) /* Tenchi o Kurau II - Shokatsu Koumei Den (J) (C).nes */
setprg8(A, V & 0x4F);
@@ -1137,7 +1119,7 @@ static void M198PW(uint32 A, uint8 V) {
void Mapper198_Init(CartInfo *info) {
GenMMC3_Init(info, 1024, 0, 16, info->battery);
pwrap = M198PW;
info->Power = M195Power;
info->Power = M198Power;
}
/* ---------------------------- Mapper 205 ------------------------------ */