Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
增加BTL-900218 Borad 支持,感谢lidnariq
  • Loading branch information
dragon2snow committed Mar 25, 2015
1 parent 4a58f41 commit 42233e2
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 0 deletions.
95 changes: 95 additions & 0 deletions fceu/trunk/src/boards/vrc2and4.cpp
Expand Up @@ -267,3 +267,98 @@ void UNLT230_Init(CartInfo *info) {
info->Power = M23Power;
VRC24_Init(info);
}


static DECLFW(BTL900218Write) {
A |= ((A >> 2) & 0x3) | ((A >> 4) & 0x3) | ((A >> 6) & 0x3);// actually there is many-in-one mapper source, some pirate or
// licensed games use various address bits for registers
A &= 0xF003;
if ((A >= 0xB000) && (A <= 0xE003)) {
if (UNIFchrrama)
big_bank = (V & 8) << 2; // my personally many-in-one feature ;) just for support pirate cart 2-in-1
else{
uint16 i = ((A >> 1) & 1) | ((A - 0xB000) >> 11);
uint16 nibble = ((A & 1) << 2);
chrreg[i] = (chrreg[i] & (0xF0 >> nibble)) | ((V & 0xF) << nibble);
if (nibble)
chrhi[i] = (V & 0x10) << 4; // another one many in one feature from pirate carts
}
Sync();
}
else
switch (A & 0xF003) {
case 0x8000:
case 0x8001:
case 0x8002:
case 0x8003:
if (!isPirate) {
prgreg[0] = V & 0x1F;
Sync();
}
break;
case 0xA000:
case 0xA001:
case 0xA002:
case 0xA003:
if (!isPirate)
prgreg[1] = V & 0x1F;
else{
prgreg[0] = (V & 0x1F) << 1;
prgreg[1] = ((V & 0x1F) << 1) | 1;
}
Sync();
break;
case 0x9000:
case 0x9001: if (V != 0xFF) mirr = V; Sync(); break;
case 0x9002:
case 0x9003: regcmd = V; Sync(); break;
case 0xF002:
//printf("0xF008 %04x %02x\n", A, V);
IRQa = 0; IRQCount = 0;
X6502_IRQEnd(FCEU_IQEXT);
break;
case 0xF003:
//printf("0xF00C %04x %02x\n", A, V);
IRQa = 1;
X6502_IRQEnd(FCEU_IQEXT);
break;
}
}
void BTL900218IRQHook(int a) {//by idnariq
IRQCount += a;
if (IRQCount & 1024) {
X6502_IRQBegin(FCEU_IQEXT);
}
}

static void BTL900218Power(void) {
big_bank = 0x20;
Sync();
setprg8r(0x10, 0x6000, 0); // Only two Goemon games are have battery backed RAM, three more shooters
// (Parodius Da!, Gradius 2 and Crisis Force uses 2k or SRAM at 6000-67FF only
SetReadHandler(0x6000, 0x7FFF, CartBR);
SetWriteHandler(0x6000, 0x7FFF, CartBW);
SetReadHandler(0x8000, 0xFFFF, CartBR);
SetWriteHandler(0x8000, 0xFFFF, BTL900218Write);
FCEU_CheatAddRAM(WRAMSIZE >> 10, 0x6000, WRAM);
}
//http://wiki.nesbbs.com/index.php?doc-view-72
void BTL900218_Init(CartInfo *info) {
isPirate = 0;
is22 = 0;
info->Power = BTL900218Power;
MapIRQHook = BTL900218IRQHook;
GameStateRestore = StateRestore;

WRAMSIZE = 8192;
WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE);
SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1);
AddExState(WRAM, WRAMSIZE, 0, "WRAM");

if (info->battery) {
info->SaveGame[0] = WRAM;
info->SaveGameLen[0] = WRAMSIZE;
}

AddExState(&StateRegs, ~0, 0, 0);
}
1 change: 1 addition & 0 deletions fceu/trunk/src/unif.cpp
Expand Up @@ -457,6 +457,7 @@ static BMAPPING bmap[] = {
{ "VRC7", UNLVRC7_Init, 0 },
{ "YOKO", UNLYOKO_Init, 0 },
{ "82112C", UNL82112C_Init, 0 },
{ "900218", BTL900218_Init, 0 },
{ "SB-2000", UNLSB2000_Init, 0 },
{ "COOLBOY", COOLBOY_Init, BMCFLAG_256KCHRR },

Expand Down
1 change: 1 addition & 0 deletions fceu/trunk/src/unif.h
Expand Up @@ -146,6 +146,7 @@ void UNROM512_Init(CartInfo *info);
void UNLSB2000_Init(CartInfo *info);
void UNLKS7010_Init(CartInfo *info);
void COOLBOY_Init(CartInfo *info);
void BTL900218_Init(CartInfo *info);

extern uint8 *UNIFchrrama; // Meh. So I can stop CHR RAM
// bank switcherooing with certain boards...

0 comments on commit 42233e2

Please sign in to comment.