support BKF23C unif and BKF23CA (big m176 multicarts)

This commit is contained in:
zeromus 2012-09-05 20:28:08 +00:00
parent bc347d475b
commit 887c93733e
5 changed files with 130 additions and 33 deletions

View File

@ -22,22 +22,33 @@
#include "mmc3.h" #include "mmc3.h"
#include "../ines.h" #include "../ines.h"
static bool is_BMCFK23CA;
static uint8 unromchr; static uint8 unromchr;
static uint32 dipswitch; static uint32 dipswitch;
static uint8 *CHRRAM=NULL;
static uint32 CHRRAMSize;
static void BMCFK23CCW(uint32 A, uint8 V) static void BMCFK23CCW(uint32 A, uint8 V)
{ {
if(EXPREGS[0]&0x40) if(EXPREGS[0]&0x40)
setchr8(EXPREGS[2]|unromchr); setchr8(EXPREGS[2]|unromchr);
else if(EXPREGS[0]&0x20) {
setchr1r(0x10, A, V);
}
else else
{ {
uint16 base=(EXPREGS[2]&0x7F)<<3; uint16 base=(EXPREGS[2]&0x7F)<<3;
setchr1(A,V|base);
if(EXPREGS[3]&2) if(EXPREGS[3]&2)
{ {
setchr1(0x0400,EXPREGS[6]|base); int cbase=(MMC3_cmd&0x80)<<5;
setchr1(0x0C00,EXPREGS[7]|base); setchr1(A,V|base);
setchr1(0x0000^cbase,DRegBuf[0]|base);
setchr1(0x0400^cbase,EXPREGS[6]|base);
setchr1(0x0800^cbase,DRegBuf[1]|base);
setchr1(0x0c00^cbase,EXPREGS[7]|base);
} }
else
setchr1(A,V|base);
} }
} }
@ -75,6 +86,11 @@ static int prg_mask;
//PRG wrapper //PRG wrapper
static void BMCFK23CPW(uint32 A, uint8 V) static void BMCFK23CPW(uint32 A, uint8 V)
{ {
uint32 bank = (EXPREGS[1] & 0x1F);
uint32 hiblock = ((EXPREGS[0] & 8) << 4)|((EXPREGS[0] & 0x80) << 1)|(UNIFchrrama?((EXPREGS[2] & 0x40)<<3):0);
uint32 block = (EXPREGS[1] & 0x60) | hiblock;
uint32 extra = (EXPREGS[3] & 2);
if((EXPREGS[0]&7)==4) if((EXPREGS[0]&7)==4)
setprg32(0x8000,EXPREGS[1]>>1); setprg32(0x8000,EXPREGS[1]>>1);
else if ((EXPREGS[0]&7)==3) else if ((EXPREGS[0]&7)==3)
@ -86,7 +102,7 @@ static void BMCFK23CPW(uint32 A, uint8 V)
{ {
if(EXPREGS[0]&3) if(EXPREGS[0]&3)
{ {
uint32 blocksize = (6+prg_bonus)-(EXPREGS[0]&3); uint32 blocksize = (6)-(EXPREGS[0]&3);
uint32 mask = (1<<blocksize)-1; uint32 mask = (1<<blocksize)-1;
V &= mask; V &= mask;
//V &= 63; //? is this a good idea? //V &= 63; //? is this a good idea?
@ -102,32 +118,42 @@ static void BMCFK23CPW(uint32 A, uint8 V)
setprg8(0xE000,EXPREGS[5]); setprg8(0xE000,EXPREGS[5]);
} }
} }
setprg8r(0x10,0x6000,A001B&3);
} }
//PRG handler ($8000-$FFFF) //PRG handler ($8000-$FFFF)
static DECLFW(BMCFK23CHiWrite) static DECLFW(BMCFK23CHiWrite)
{ {
if(EXPREGS[0]&0x40) if(EXPREGS[0]&0x40)
{ {
if(EXPREGS[0]&0x30) if(EXPREGS[0]&0x30)
unromchr=0; unromchr=0;
else
{
unromchr=V&3;
FixMMC3CHR(MMC3_cmd);
}
}
else
{
if((A==0x8001)&&(EXPREGS[3]&2&&MMC3_cmd&8))
{
EXPREGS[4|(MMC3_cmd&3)]=V;
FixMMC3PRG(MMC3_cmd);
FixMMC3CHR(MMC3_cmd);
}
else else
{ if(A<0xC000) {
unromchr=V&3; if(UNIFchrrama) { // hacky... strange behaviour, must be bit scramble due to pcb layot restrictions
FixMMC3CHR(MMC3_cmd); // check if it not interfer with other dumps
} if((A==0x8000)&&(V==0x46))
} V=0x47;
else else if((A==0x8000)&&(V==0x47))
{ V=0x46;
if((A==0x8001)&&(EXPREGS[3]&2&&MMC3_cmd&8)) }
{
EXPREGS[4|(MMC3_cmd&3)]=V;
FixMMC3PRG(MMC3_cmd);
FixMMC3CHR(MMC3_cmd);
}
else
if(A<0xC000)
MMC3_CMDWrite(A,V); MMC3_CMDWrite(A,V);
FixMMC3PRG(MMC3_cmd);
}
else else
MMC3_IRQWrite(A,V); MMC3_IRQWrite(A,V);
} }
@ -159,19 +185,25 @@ static DECLFW(BMCFK23CWrite)
FixMMC3PRG(MMC3_cmd); FixMMC3PRG(MMC3_cmd);
FixMMC3CHR(MMC3_cmd); FixMMC3CHR(MMC3_cmd);
} }
} }
//else printf("- ");
//printf("%04X = $%02X\n",A,V);
if(is_BMCFK23CA)
{
if(EXPREGS[3]&2)
EXPREGS[0] &= ~7; // hacky hacky! if someone wants extra banking, then for sure doesn't want mode 4 for it! (allow to run A version boards on normal mapper)
}
//printf("%04X = $%02X\n",A,V);
//printf("%02X %02X %02X %02X\n",EXPREGS[0],EXPREGS[1],EXPREGS[2],EXPREGS[3]); //printf("%02X %02X %02X %02X\n",EXPREGS[0],EXPREGS[1],EXPREGS[2],EXPREGS[3]);
} }
static void BMCFK23CReset(void) static void BMCFK23CReset(void)
{ {
//NOT NECESSARY ANYMORE
//this little hack makes sure that we try all the dip switch settings eventually, if we reset enough //this little hack makes sure that we try all the dip switch settings eventually, if we reset enough
dipswitch++; // dipswitch++;
dipswitch&=7; // dipswitch&=7;
printf("BMCFK23C dipswitch set to %d\n",dipswitch); //printf("BMCFK23C dipswitch set to %d\n",dipswitch);
EXPREGS[0]=EXPREGS[1]=EXPREGS[2]=EXPREGS[3]=0; EXPREGS[0]=EXPREGS[1]=EXPREGS[2]=EXPREGS[3]=0;
EXPREGS[4]=EXPREGS[5]=EXPREGS[6]=EXPREGS[7]=0xFF; EXPREGS[4]=EXPREGS[5]=EXPREGS[6]=EXPREGS[7]=0xFF;
@ -191,11 +223,31 @@ static void BMCFK23CPower(void)
SetWriteHandler(0x8000,0xFFFF,BMCFK23CHiWrite); SetWriteHandler(0x8000,0xFFFF,BMCFK23CHiWrite);
FixMMC3PRG(MMC3_cmd); FixMMC3PRG(MMC3_cmd);
FixMMC3CHR(MMC3_cmd); FixMMC3CHR(MMC3_cmd);
}
static void BMCFK23CAPower(void)
{
GenMMC3Power();
dipswitch = 0;
EXPREGS[0]=EXPREGS[1]=EXPREGS[2]=EXPREGS[3]=0;
EXPREGS[4]=EXPREGS[5]=EXPREGS[6]=EXPREGS[7]=0xFF;
SetWriteHandler(0x5000,0x5fff,BMCFK23CWrite);
SetWriteHandler(0x8000,0xFFFF,BMCFK23CHiWrite);
FixMMC3PRG(MMC3_cmd);
FixMMC3CHR(MMC3_cmd);
}
static void BMCFK23CAClose(void)
{
if(CHRRAM)
FCEU_gfree(CHRRAM);
CHRRAM=NULL;
} }
void BMCFK23C_Init(CartInfo *info) void BMCFK23C_Init(CartInfo *info)
{ {
is_BMCFK23CA = false;
GenMMC3_Init(info, 512, 256, 8, 0); GenMMC3_Init(info, 512, 256, 8, 0);
cwrap=BMCFK23CCW; cwrap=BMCFK23CCW;
pwrap=BMCFK23CPW; pwrap=BMCFK23CPW;
@ -211,3 +263,29 @@ void BMCFK23C_Init(CartInfo *info)
prg_mask = 0x7F>>(prg_bonus); prg_mask = 0x7F>>(prg_bonus);
} }
void BMCFK23CA_Init(CartInfo *info)
{
is_BMCFK23CA = true;
GenMMC3_Init(info, 512, 256, 8, 0);
cwrap=BMCFK23CCW;
pwrap=BMCFK23CPW;
info->Power=BMCFK23CAPower;
info->Reset=BMCFK23CReset;
info->Close=BMCFK23CAClose;
CHRRAMSize=8192;
CHRRAM=(uint8*)FCEU_gmalloc(CHRRAMSize);
SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSize, 1);
AddExState(CHRRAM, CHRRAMSize, 0, "CRAM");
AddExState(EXPREGS, 8, 0, "EXPR");
AddExState(&unromchr, 1, 0, "UNCHR");
AddExState(&dipswitch, 1, 0, "DIPSW");
prg_bonus = 1;
if(MasterRomInfoParams.find("bonus") != MasterRomInfoParams.end())
prg_bonus = atoi(MasterRomInfoParams["bonus"].c_str());
prg_mask = 0x7F>>(prg_bonus);
}

View File

@ -1,4 +1,6 @@
extern uint8 MMC3_cmd; extern uint8 MMC3_cmd;
extern uint8 A000B;
extern uint8 A001B;
extern uint8 EXPREGS[8]; extern uint8 EXPREGS[8];
extern uint8 DRegBuf[8]; extern uint8 DRegBuf[8];

View File

@ -313,6 +313,7 @@ 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
static BMAPPING bmap[] = { static BMAPPING bmap[] = {
@ -438,6 +439,9 @@ static BMAPPING bmap[] = {
{ "TEK90", Mapper90_Init,0}, { "TEK90", Mapper90_Init,0},
{ "FK23C", BMCFK23C_Init,BMCFLAG_EXPCHRR},
{ "FK23CA", BMCFK23CA_Init,BMCFLAG_EXPCHRR},
{0,0,0} {0,0,0}
}; };
@ -501,10 +505,14 @@ static int InitializeBoard(void)
{ {
if(!malloced[16]) if(!malloced[16])
{ {
if(bmap[x].flags & BMCFLAG_16KCHRR) if(bmap[x].flags & BMCFLAG_16KCHRR)
CHRRAMSize = 16384; CHRRAMSize = 16384;
else else if(bmap[x].flags & BMCFLAG_32KCHRR)
CHRRAMSize = 8192; CHRRAMSize = 32768;
else if(bmap[x].flags & BMCFLAG_EXPCHRR)
CHRRAMSize = 128 * 1024;
else
CHRRAMSize = 8192;
if((UNIFchrrama=(uint8 *)FCEU_malloc(CHRRAMSize))) if((UNIFchrrama=(uint8 *)FCEU_malloc(CHRRAMSize)))
{ {
SetupCartCHRMapping(0,UNIFchrrama,CHRRAMSize,1); SetupCartCHRMapping(0,UNIFchrrama,CHRRAMSize,1);

View File

@ -89,6 +89,7 @@ void BMC70in1B_Init(CartInfo *info);
void BMC13in1JY110_Init(CartInfo *info); void BMC13in1JY110_Init(CartInfo *info);
void BMCT262_Init(CartInfo *info); void BMCT262_Init(CartInfo *info);
void BMCFK23C_Init(CartInfo *info); void BMCFK23C_Init(CartInfo *info);
void BMCFK23CA_Init(CartInfo *info);
void BMCD1038_Init(CartInfo *info); void BMCD1038_Init(CartInfo *info);
void BMCA65AS_Init(CartInfo *info); void BMCA65AS_Init(CartInfo *info);
void BMCGK192_Init(CartInfo *info); void BMCGK192_Init(CartInfo *info);

View File

@ -592,6 +592,14 @@
<File <File
RelativePath="..\src\mappers\156.cpp" RelativePath="..\src\mappers\156.cpp"
> >
<FileConfiguration
Name="Release Fastbuild|Win32"
>
<Tool
Name="VCCLCompilerTool"
WarningLevel="4"
/>
</FileConfiguration>
</File> </File>
<File <File
RelativePath="..\src\boards\164.cpp" RelativePath="..\src\boards\164.cpp"