Backport r164 -
mapper 4 - fixed savestates for mmc3 based mappers broken with kt-008 board UNIF COOLBOY - new dump support
This commit is contained in:
92
src/boards/coolboy.c
Normal file
92
src/boards/coolboy.c
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
/* FCE Ultra - NES/Famicom Emulator
|
||||||
|
*
|
||||||
|
* Copyright notice for this file:
|
||||||
|
* Copyright (C) 2015 CaH4e3
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
*
|
||||||
|
* CoolBoy 400-in-1 FK23C-mimic mapper 32Mb PROM + 128K CHR RAM, no wram, no CROM
|
||||||
|
* only MMC3 mode
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "mapinc.h"
|
||||||
|
#include "mmc3.h"
|
||||||
|
|
||||||
|
static void COOLBOYCW(uint32 A, uint8 V) {
|
||||||
|
if(EXPREGS[3] & 0x10)
|
||||||
|
setchr8(EXPREGS[2] & 0xF);
|
||||||
|
else
|
||||||
|
setchr1(A, V);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void COOLBOYPW(uint32 A, uint8 V) {
|
||||||
|
uint32 mask, shift;
|
||||||
|
uint32 base = ((EXPREGS[0] & 0x07) >> 0) | ((EXPREGS[1] & 0x10) >> 1) | ((EXPREGS[1] & 0x0C) << 2) | ((EXPREGS[0] & 0x30) << 2);
|
||||||
|
switch(EXPREGS[0]&0xC0) {
|
||||||
|
case 0x00:
|
||||||
|
mask = 0x3F;
|
||||||
|
shift = 6;
|
||||||
|
break;
|
||||||
|
case 0xC0:
|
||||||
|
shift = 4;
|
||||||
|
if(EXPREGS[3] & 0x10) {
|
||||||
|
mask = 0x03;
|
||||||
|
} else {
|
||||||
|
mask = 0x0F;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if(EXPREGS[3] & 0x10)
|
||||||
|
setprg8(A, (base << shift) | (V & mask) | (EXPREGS[3] & 0x0C) /*| EXPREGS[2] & 2*/);
|
||||||
|
else
|
||||||
|
setprg8(A, (base << shift) | (V & mask));
|
||||||
|
}
|
||||||
|
|
||||||
|
static DECLFW(COOLBOYWrite) {
|
||||||
|
if((EXPREGS[3] & 0x80) == 0) {
|
||||||
|
EXPREGS[A & 3] = V;
|
||||||
|
FixMMC3PRG(MMC3_cmd);
|
||||||
|
FixMMC3CHR(MMC3_cmd);
|
||||||
|
uint32 base = ((EXPREGS[0] & 0x07) >> 0) | ((EXPREGS[1] & 0x10) >> 1) | ((EXPREGS[1] & 0x0C) << 2) | ((EXPREGS[0] & 0x30) << 2);
|
||||||
|
FCEU_printf("exp %02x %02x (base %03d)\n",A,V,base);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void COOLBOYReset(void) {
|
||||||
|
MMC3RegReset();
|
||||||
|
EXPREGS[0] = EXPREGS[1] = EXPREGS[2] = EXPREGS[3] = 0;
|
||||||
|
FixMMC3PRG(MMC3_cmd);
|
||||||
|
FixMMC3CHR(MMC3_cmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void COOLBOYPower(void) {
|
||||||
|
GenMMC3Power();
|
||||||
|
EXPREGS[0] = EXPREGS[1] = EXPREGS[2] = EXPREGS[3] = 0;
|
||||||
|
FixMMC3PRG(MMC3_cmd);
|
||||||
|
FixMMC3CHR(MMC3_cmd);
|
||||||
|
SetWriteHandler(0x5000, 0x5fff, CartBW); // some games access random unmapped areas and crashes because of KT-008 PCB hack in MMC3 source lol
|
||||||
|
SetWriteHandler(0x6000, 0x6fff, COOLBOYWrite);
|
||||||
|
}
|
||||||
|
|
||||||
|
void COOLBOY_Init(CartInfo *info) {
|
||||||
|
GenMMC3_Init(info, 512, 128, 0, 0);
|
||||||
|
pwrap = COOLBOYPW;
|
||||||
|
cwrap = COOLBOYCW;
|
||||||
|
info->Power = COOLBOYPower;
|
||||||
|
info->Reset = COOLBOYReset;
|
||||||
|
AddExState(EXPREGS, 4, 0, "EXPR");
|
||||||
|
}
|
||||||
|
|
||||||
@@ -28,6 +28,7 @@
|
|||||||
#include "mmc3.h"
|
#include "mmc3.h"
|
||||||
|
|
||||||
uint8 MMC3_cmd;
|
uint8 MMC3_cmd;
|
||||||
|
uint8 kt_extra;
|
||||||
uint8 *WRAM;
|
uint8 *WRAM;
|
||||||
uint32 WRAMSIZE;
|
uint32 WRAMSIZE;
|
||||||
uint8 *CHRRAM;
|
uint8 *CHRRAM;
|
||||||
@@ -186,7 +187,7 @@ DECLFW(MMC3_IRQWrite) {
|
|||||||
DECLFW(KT008HackWrite) {
|
DECLFW(KT008HackWrite) {
|
||||||
// FCEU_printf("%04x:%04x\n",A,V);
|
// FCEU_printf("%04x:%04x\n",A,V);
|
||||||
switch (A & 3) {
|
switch (A & 3) {
|
||||||
case 0: EXPREGS[0] = V; FixMMC3PRG(MMC3_cmd); break;
|
case 0: kt_extra = V; FixMMC3PRG(MMC3_cmd); break;
|
||||||
case 1: break; // unk
|
case 1: break; // unk
|
||||||
case 2: break; // unk
|
case 2: break; // unk
|
||||||
case 3: break; // unk
|
case 3: break; // unk
|
||||||
@@ -233,7 +234,7 @@ static void GENCWRAP(uint32 A, uint8 V) {
|
|||||||
static void GENPWRAP(uint32 A, uint8 V) {
|
static void GENPWRAP(uint32 A, uint8 V) {
|
||||||
// [NJ102] Mo Dao Jie (C) has 1024Mb MMC3 BOARD, maybe something other will be broken
|
// [NJ102] Mo Dao Jie (C) has 1024Mb MMC3 BOARD, maybe something other will be broken
|
||||||
// also HengGe BBC-2x boards enables this mode as default board mode at boot up
|
// also HengGe BBC-2x boards enables this mode as default board mode at boot up
|
||||||
setprg8(A, (V & 0x7F) | ((EXPREGS[0] & 4) << 4));
|
setprg8(A, (V & 0x7F) | ((kt_extra & 4) << 4));
|
||||||
// KT-008 boards hack 2-in-1, TODO assign to new ines mapper, most dump of KT-boards on the net are mapper 4, so need database or goodnes fix support
|
// KT-008 boards hack 2-in-1, TODO assign to new ines mapper, most dump of KT-boards on the net are mapper 4, so need database or goodnes fix support
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -318,7 +319,7 @@ void GenMMC3_Init(CartInfo *info, int prg, int chr, int wram, int battery) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// KT-008 boards hack 2-in-1, TODO assign to new ines mapper, most dump of KT-boards on the net are mapper 4, so need database or goodnes fix support
|
// KT-008 boards hack 2-in-1, TODO assign to new ines mapper, most dump of KT-boards on the net are mapper 4, so need database or goodnes fix support
|
||||||
AddExState(EXPREGS, 1, 0, "EXPR");
|
AddExState(&kt_extra, 1, 0, "KTEX");
|
||||||
AddExState(MMC3_StateRegs, ~0, 0, 0);
|
AddExState(MMC3_StateRegs, ~0, 0, 0);
|
||||||
|
|
||||||
info->Power = GenMMC3Power;
|
info->Power = GenMMC3Power;
|
||||||
|
|||||||
@@ -312,7 +312,8 @@ static int LoadCHR(FCEUFILE *fp) {
|
|||||||
#define BMCFLAG_FORCE4 1
|
#define BMCFLAG_FORCE4 1
|
||||||
#define BMCFLAG_16KCHRR 2
|
#define BMCFLAG_16KCHRR 2
|
||||||
#define BMCFLAG_32KCHRR 4
|
#define BMCFLAG_32KCHRR 4
|
||||||
#define BMCFLAG_EXPCHRR 8
|
#define BMCFLAG_128KCHRR 8
|
||||||
|
#define BMCFLAG_EXPCHRR 10
|
||||||
|
|
||||||
static BMAPPING bmap[] = {
|
static BMAPPING bmap[] = {
|
||||||
{ "11160", BMC11160_Init, 0 },
|
{ "11160", BMC11160_Init, 0 },
|
||||||
@@ -448,6 +449,7 @@ static BMAPPING bmap[] = {
|
|||||||
{ "UOROM", UNROM_Init, 0 },
|
{ "UOROM", UNROM_Init, 0 },
|
||||||
{ "VRC7", UNLVRC7_Init, 0 },
|
{ "VRC7", UNLVRC7_Init, 0 },
|
||||||
{ "YOKO", UNLYOKO_Init, 0 },
|
{ "YOKO", UNLYOKO_Init, 0 },
|
||||||
|
{ "COOLBOY", COOLBOY_Init, BMCFLAG_128KCHRR },
|
||||||
|
|
||||||
#ifdef COPYFAMI
|
#ifdef COPYFAMI
|
||||||
{ "COPYFAMI_MMC3", MapperCopyFamiMMC3_Init, 0 },
|
{ "COPYFAMI_MMC3", MapperCopyFamiMMC3_Init, 0 },
|
||||||
@@ -508,13 +510,16 @@ static int InitializeBoard(void) {
|
|||||||
if (!strcmp((char*)sboardname, (char*)bmap[x].name)) {
|
if (!strcmp((char*)sboardname, (char*)bmap[x].name)) {
|
||||||
if (!malloced[16]) {
|
if (!malloced[16]) {
|
||||||
if (bmap[x].flags & BMCFLAG_16KCHRR)
|
if (bmap[x].flags & BMCFLAG_16KCHRR)
|
||||||
CHRRAMSize = 16384;
|
CHRRAMSize = 16;
|
||||||
else if (bmap[x].flags & BMCFLAG_32KCHRR)
|
else if (bmap[x].flags & BMCFLAG_32KCHRR)
|
||||||
CHRRAMSize = 32768;
|
CHRRAMSize = 32;
|
||||||
|
else if (bmap[x].flags & BMCFLAG_128KCHRR)
|
||||||
|
CHRRAMSize = 128;
|
||||||
else if (bmap[x].flags & BMCFLAG_EXPCHRR)
|
else if (bmap[x].flags & BMCFLAG_EXPCHRR)
|
||||||
CHRRAMSize = 256 * 1024;
|
CHRRAMSize = 256;
|
||||||
else
|
else
|
||||||
CHRRAMSize = 8192;
|
CHRRAMSize = 8;
|
||||||
|
CHRRAMSize <<= 10;
|
||||||
if ((UNIFchrrama = (uint8*)FCEU_malloc(CHRRAMSize))) {
|
if ((UNIFchrrama = (uint8*)FCEU_malloc(CHRRAMSize))) {
|
||||||
SetupCartCHRMapping(0, UNIFchrrama, CHRRAMSize, 1);
|
SetupCartCHRMapping(0, UNIFchrrama, CHRRAMSize, 1);
|
||||||
AddExState(UNIFchrrama, CHRRAMSize, 0, "CHRR");
|
AddExState(UNIFchrrama, CHRRAMSize, 0, "CHRR");
|
||||||
|
|||||||
@@ -145,6 +145,7 @@ void UNLTF1201_Init(CartInfo *info);
|
|||||||
void UNLVRC7_Init(CartInfo *info);
|
void UNLVRC7_Init(CartInfo *info);
|
||||||
void UNLYOKO_Init(CartInfo *info);
|
void UNLYOKO_Init(CartInfo *info);
|
||||||
void UNROM_Init(CartInfo *info);
|
void UNROM_Init(CartInfo *info);
|
||||||
|
void COOLBOY_Init(CartInfo *info);
|
||||||
|
|
||||||
#ifdef COPYFAMI
|
#ifdef COPYFAMI
|
||||||
void MapperCopyFamiMMC3_Init(CartInfo *info);
|
void MapperCopyFamiMMC3_Init(CartInfo *info);
|
||||||
|
|||||||
Reference in New Issue
Block a user