Backport r169

This commit is contained in:
twinaphex
2015-03-06 13:50:22 +01:00
parent 068790526a
commit 7962b4f9d9
2 changed files with 41 additions and 33 deletions

View File

@@ -17,9 +17,14 @@
* 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
* CoolBoy 400-in-1 FK23C-mimic mapper 16Mb/32Mb PROM + 128K/256K CHR RAM, optional SRAM, optional NTRAM
* only MMC3 mode
*
* 6000 (õõ76x210) | 0õÑ0
* 6001 (õõõ354õõ)
* 6002 = 0
* 6003 = 0
*
*/
#include "mapinc.h"
@@ -28,50 +33,52 @@
static void COOLBOYCW(uint32 A, uint8 V) {
if(EXPREGS[3] & 0x10)
setchr8(EXPREGS[2] & 0xF);
else
setchr1(A, V);
else {
uint32 mask = 0xFF;
switch(EXPREGS[0] & 0xC0) {
case 0xC0:
mask = 0x7F;
break;
}
setchr1(A, V & mask);
}
}
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) {
switch(EXPREGS[0] & 0xC0) {
case 0x00:
base >>= 2;
mask = 0x3F;
shift = 6;
break;
case 0x80:
base >>= 1;
mask = 0x1F;
shift = 5;
break;
case 0x80:
mask = 0x1F;
break;
case 0xC0:
shift = 4;
if(EXPREGS[3] & 0x10) {
mask = 0x01 | (EXPREGS[1] & 2);
mask = 0x01 | (EXPREGS[1] & 2);
} else {
mask = 0x0F;
}
break;
}
if(EXPREGS[3] & 0x10)
setprg8(A, (base << shift) | (V & mask) | ((EXPREGS[3] & (0x0E ^ (EXPREGS[1] & 2))) ));
setprg8(A, (base << 4) | (V & mask) | ((EXPREGS[3] & (0x0E ^ (EXPREGS[1] & 2))) ));
else
setprg8(A, (base << shift) | (V & mask));
setprg8(A, (base << 4) | (V & mask));
}
static DECLFW(COOLBOYWrite) {
uint32_t base;
if((EXPREGS[3] & 0x80) == 0)
{
EXPREGS[A & 3] = V;
FixMMC3PRG(MMC3_cmd);
FixMMC3CHR(MMC3_cmd);
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);
}
if(A001B & 0x80)
CartBW(A,V);
else
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) {
@@ -91,11 +98,10 @@ static void COOLBOYPower(void) {
}
void COOLBOY_Init(CartInfo *info) {
GenMMC3_Init(info, 512, 128, 0, 0);
GenMMC3_Init(info, 512, 128, 8, 0);
pwrap = COOLBOYPW;
cwrap = COOLBOYCW;
info->Power = COOLBOYPower;
info->Reset = COOLBOYReset;
AddExState(EXPREGS, 4, 0, "EXPR");
}

View File

@@ -309,10 +309,11 @@ static int LoadCHR(FCEUFILE *fp) {
return(1);
}
#define BMCFLAG_FORCE4 1
#define BMCFLAG_16KCHRR 2
#define BMCFLAG_32KCHRR 4
#define BMCFLAG_EXPCHRR 8
#define BMCFLAG_FORCE4 0x01
#define BMCFLAG_16KCHRR 0x02
#define BMCFLAG_32KCHRR 0x04
#define BMCFLAG_128KCHRR 0x08
#define BMCFLAG_256KCHRR 0x10
static BMAPPING bmap[] = {
{ "11160", BMC11160_Init, 0 },
@@ -352,8 +353,8 @@ static BMAPPING bmap[] = {
{ "ELROM", ELROM_Init, 0 },
{ "ETROM", ETROM_Init, 0 },
{ "EWROM", EWROM_Init, 0 },
{ "FK23C", BMCFK23C_Init, BMCFLAG_EXPCHRR },
{ "FK23CA", BMCFK23CA_Init, BMCFLAG_EXPCHRR },
{ "FK23C", BMCFK23C_Init, BMCFLAG_256KCHRR },
{ "FK23CA", BMCFK23CA_Init, BMCFLAG_256KCHRR },
{ "FS304", UNLFS304_Init, 0 },
{ "G-146", BMCG146_Init, 0 },
{ "GK-192", BMCGK192_Init, 0 },
@@ -448,6 +449,7 @@ static BMAPPING bmap[] = {
{ "UOROM", UNROM_Init, 0 },
{ "VRC7", UNLVRC7_Init, 0 },
{ "YOKO", UNLYOKO_Init, 0 },
{ "COOLBOY", COOLBOY_Init, BMCFLAG_256KCHRR },
#ifdef COPYFAMI
{ "COPYFAMI_MMC3", MapperCopyFamiMMC3_Init, 0 },