Add submapper 1 to mapper 452
This commit is contained in:
104
src/boards/452.c
104
src/boards/452.c
@@ -26,36 +26,77 @@
|
|||||||
static uint8 *WRAM;
|
static uint8 *WRAM;
|
||||||
static uint32 WRAMSIZE;
|
static uint32 WRAMSIZE;
|
||||||
static uint16 latch[2];
|
static uint16 latch[2];
|
||||||
|
static uint8 submapper;
|
||||||
|
|
||||||
|
static void SetWRAM(uint16 A) {
|
||||||
|
setprg8r(0x10, A, 0);
|
||||||
|
SetWriteHandler(A, A |0x1FFF, CartBW);
|
||||||
|
}
|
||||||
|
|
||||||
|
static DECLFW(Mapper452_WriteLatch);
|
||||||
static void Mapper452_Sync(void) {
|
static void Mapper452_Sync(void) {
|
||||||
uint8 wramBank = latch[1] >>3 &6 |8;
|
SetWriteHandler(0x8000, 0xFFFF, Mapper452_WriteLatch);
|
||||||
if (latch[1] &2) {
|
if (submapper ==1) {
|
||||||
setprg8(0x8000, latch[0] >>1);
|
switch(latch[0] &0xF000) {
|
||||||
setprg8(0xA000, latch[0] >>1);
|
case 0xA000:
|
||||||
setprg8(0xC000, latch[0] >>1);
|
setprg16(0x8000, latch[0] >>1);
|
||||||
setprg8(0xE000, latch[0] >>1);
|
setprg8 (0xC000, 0);
|
||||||
setprg8r(0x10, (wramBank ^4) <<12, 0);
|
SetWRAM(latch[0] <<4 &0x6000 |0x8000);
|
||||||
} else
|
break;
|
||||||
if (latch[1] &8) {
|
case 0xC000:
|
||||||
setprg8(0x8000, latch[0] >>1 &~1 |0);
|
setprg16(0x8000, latch[0] >>1 |0);
|
||||||
setprg8(0xA000, latch[0] >>1 &~1 |1);
|
setprg16(0xC000, latch[0] >>1 |1);
|
||||||
setprg8(0xC000, latch[0] >>1 &~1 |2);
|
SetWRAM(latch[0] <<4 &0x6000 |0x8000);
|
||||||
setprg8(0xE000, latch[0] >>1 &~1 |3 | latch[1] &4 | (latch[1] &0x04 && latch[1] &0x40? 8: 0));
|
break;
|
||||||
|
case 0xD000:
|
||||||
|
setprg8(0x8000, latch[0]);
|
||||||
|
setprg8(0xA000, latch[0]);
|
||||||
|
setprg8(0xC000, latch[0]);
|
||||||
|
setprg8(0xE000, latch[0]);
|
||||||
|
SetWRAM(latch[0] <<4 &0x2000 |0x8000);
|
||||||
|
SetWRAM(latch[0] <<4 &0x2000 |0xC000);
|
||||||
|
break;
|
||||||
|
case 0xE000:
|
||||||
|
setprg16(0x8000, latch[0] >>1);
|
||||||
|
setprg16(0xC000, latch[0] &0x100? (latch[0] >>1 |7): 0);
|
||||||
|
SetWRAM(latch[0] <<4 &0x6000 |0x8000);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
setprg16(0x8000, latch[0] >>1);
|
||||||
|
setprg16(0xC000, 0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
setchr8(0);
|
||||||
|
setmirror(latch[0] &0x800? MI_H: MI_V);
|
||||||
} else {
|
} else {
|
||||||
setprg16(0x8000, latch[0] >>2);
|
uint8 wramBank = latch[1] >>3 &6 |8;
|
||||||
setprg16(0xC000, 0);
|
if (latch[1] &2) {
|
||||||
|
setprg8(0x8000, latch[0] >>1);
|
||||||
|
setprg8(0xA000, latch[0] >>1);
|
||||||
|
setprg8(0xC000, latch[0] >>1);
|
||||||
|
setprg8(0xE000, latch[0] >>1);
|
||||||
|
SetWRAM((wramBank ^4) <<12);
|
||||||
|
} else
|
||||||
|
if (latch[1] &8) {
|
||||||
|
setprg8(0x8000, latch[0] >>1 &~1 |0);
|
||||||
|
setprg8(0xA000, latch[0] >>1 &~1 |1);
|
||||||
|
setprg8(0xC000, latch[0] >>1 &~1 |2);
|
||||||
|
setprg8(0xE000, latch[0] >>1 &~1 |3 | latch[1] &4 | (latch[1] &0x04 && latch[1] &0x40? 8: 0));
|
||||||
|
} else {
|
||||||
|
setprg16(0x8000, latch[0] >>2);
|
||||||
|
setprg16(0xC000, 0);
|
||||||
|
}
|
||||||
|
SetWRAM(wramBank <<12);
|
||||||
|
setchr8(0);
|
||||||
|
setmirror(latch [1] &1 ^1);
|
||||||
}
|
}
|
||||||
setprg8r(0x10, wramBank <<12, 0);
|
|
||||||
setchr8(0);
|
|
||||||
setmirror(latch [1] &1 ^1);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static DECLFW(Mapper452_WriteLatch) {
|
static DECLFW(Mapper452_WriteLatch) {
|
||||||
latch[0] =A &0xFFF;
|
CartBW(A, V);
|
||||||
|
latch[0] =A &0xFFFF;
|
||||||
latch[1] =V;
|
latch[1] =V;
|
||||||
Mapper452_Sync();
|
Mapper452_Sync();
|
||||||
/* Do not relay to CartBW, as RAM mapped to locations other than $8000-$DFFF are not write-enabled. */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Mapper452_Reset(void) {
|
static void Mapper452_Reset(void) {
|
||||||
@@ -64,35 +105,32 @@ static void Mapper452_Reset(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void Mapper452_Power(void) {
|
static void Mapper452_Power(void) {
|
||||||
|
|
||||||
latch[0] =latch[1] =0;
|
latch[0] =latch[1] =0;
|
||||||
|
SetReadHandler(0x6000, 0xFFFF, CartBR);
|
||||||
Mapper452_Sync();
|
Mapper452_Sync();
|
||||||
SetReadHandler(0x8000, 0xFFFF, CartBR);
|
FCEU_CheatAddRAM(WRAMSIZE >> 10, 0x6000, WRAM);
|
||||||
SetWriteHandler(0x8000, 0xDFFF, Mapper452_WriteLatch);
|
|
||||||
SetWriteHandler(0xE000, 0xFFFF, CartBW);
|
|
||||||
FCEU_CheatAddRAM(WRAMSIZE >> 10, 0x6000, WRAM);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Mapper452_Close(void) {
|
static void Mapper452_Close(void) {
|
||||||
if (WRAM)
|
if (WRAM)
|
||||||
FCEU_gfree(WRAM);
|
FCEU_gfree(WRAM);
|
||||||
WRAM = NULL;
|
WRAM = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void StateRestore(int version) {
|
static void StateRestore(int version) {
|
||||||
Mapper452_Sync();
|
Mapper452_Sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Mapper452_Init(CartInfo *info) {
|
void Mapper452_Init(CartInfo *info) {
|
||||||
|
submapper =info->submapper;
|
||||||
info->Reset = Mapper452_Reset;
|
info->Reset = Mapper452_Reset;
|
||||||
info->Power = Mapper452_Power;
|
info->Power = Mapper452_Power;
|
||||||
info->Close = Mapper452_Close;
|
info->Close = Mapper452_Close;
|
||||||
GameStateRestore = StateRestore;
|
GameStateRestore = StateRestore;
|
||||||
|
|
||||||
WRAMSIZE = 8192;
|
WRAMSIZE =8192;
|
||||||
WRAM = (uint8*) FCEU_gmalloc(WRAMSIZE);
|
WRAM =(uint8*) FCEU_gmalloc(WRAMSIZE);
|
||||||
SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1);
|
SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1);
|
||||||
AddExState(WRAM, WRAMSIZE, 0, "WRAM");
|
AddExState(WRAM, WRAMSIZE, 0, "WRAM");
|
||||||
|
|
||||||
AddExState(&latch, 4, 0, "LATC");
|
AddExState(&latch, 4, 0, "LATC");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user