diff --git a/src/boards/fk23c.cpp b/src/boards/fk23c.cpp index 9617cdf3..7679d0ff 100644 --- a/src/boards/fk23c.cpp +++ b/src/boards/fk23c.cpp @@ -22,22 +22,33 @@ #include "mmc3.h" #include "../ines.h" +static bool is_BMCFK23CA; static uint8 unromchr; static uint32 dipswitch; +static uint8 *CHRRAM=NULL; +static uint32 CHRRAMSize; static void BMCFK23CCW(uint32 A, uint8 V) { if(EXPREGS[0]&0x40) setchr8(EXPREGS[2]|unromchr); + else if(EXPREGS[0]&0x20) { + setchr1r(0x10, A, V); + } else { uint16 base=(EXPREGS[2]&0x7F)<<3; - setchr1(A,V|base); if(EXPREGS[3]&2) { - setchr1(0x0400,EXPREGS[6]|base); - setchr1(0x0C00,EXPREGS[7]|base); + int cbase=(MMC3_cmd&0x80)<<5; + 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 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) setprg32(0x8000,EXPREGS[1]>>1); else if ((EXPREGS[0]&7)==3) @@ -86,7 +102,7 @@ static void BMCFK23CPW(uint32 A, uint8 V) { if(EXPREGS[0]&3) { - uint32 blocksize = (6+prg_bonus)-(EXPREGS[0]&3); + uint32 blocksize = (6)-(EXPREGS[0]&3); uint32 mask = (1<>(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); +} diff --git a/src/boards/mmc3.h b/src/boards/mmc3.h index 558f8c3b..a5e03cde 100644 --- a/src/boards/mmc3.h +++ b/src/boards/mmc3.h @@ -1,4 +1,6 @@ extern uint8 MMC3_cmd; +extern uint8 A000B; +extern uint8 A001B; extern uint8 EXPREGS[8]; extern uint8 DRegBuf[8]; diff --git a/src/unif.cpp b/src/unif.cpp index 5308c5c9..22ee5ff1 100644 --- a/src/unif.cpp +++ b/src/unif.cpp @@ -313,6 +313,7 @@ static int LoadCHR(FCEUFILE *fp) #define BMCFLAG_FORCE4 1 #define BMCFLAG_16KCHRR 2 #define BMCFLAG_32KCHRR 4 +#define BMCFLAG_EXPCHRR 8 static BMAPPING bmap[] = { @@ -438,6 +439,9 @@ static BMAPPING bmap[] = { { "TEK90", Mapper90_Init,0}, + { "FK23C", BMCFK23C_Init,BMCFLAG_EXPCHRR}, + { "FK23CA", BMCFK23CA_Init,BMCFLAG_EXPCHRR}, + {0,0,0} }; @@ -501,10 +505,14 @@ static int InitializeBoard(void) { if(!malloced[16]) { - if(bmap[x].flags & BMCFLAG_16KCHRR) - CHRRAMSize = 16384; - else - CHRRAMSize = 8192; + if(bmap[x].flags & BMCFLAG_16KCHRR) + CHRRAMSize = 16384; + else if(bmap[x].flags & BMCFLAG_32KCHRR) + CHRRAMSize = 32768; + else if(bmap[x].flags & BMCFLAG_EXPCHRR) + CHRRAMSize = 128 * 1024; + else + CHRRAMSize = 8192; if((UNIFchrrama=(uint8 *)FCEU_malloc(CHRRAMSize))) { SetupCartCHRMapping(0,UNIFchrrama,CHRRAMSize,1); diff --git a/src/unif.h b/src/unif.h index 46c884b8..159ec38e 100644 --- a/src/unif.h +++ b/src/unif.h @@ -89,6 +89,7 @@ void BMC70in1B_Init(CartInfo *info); void BMC13in1JY110_Init(CartInfo *info); void BMCT262_Init(CartInfo *info); void BMCFK23C_Init(CartInfo *info); +void BMCFK23CA_Init(CartInfo *info); void BMCD1038_Init(CartInfo *info); void BMCA65AS_Init(CartInfo *info); void BMCGK192_Init(CartInfo *info); diff --git a/vc/vc8_fceux.vcproj b/vc/vc8_fceux.vcproj index 52df6507..f12e1792 100644 --- a/vc/vc8_fceux.vcproj +++ b/vc/vc8_fceux.vcproj @@ -592,6 +592,14 @@ + + +