diff --git a/src/boards/AbG1l.c b/src/boards/428.c similarity index 50% rename from src/boards/AbG1l.c rename to src/boards/428.c index 7fde82b..06f18f7 100644 --- a/src/boards/AbG1l.c +++ b/src/boards/428.c @@ -25,7 +25,6 @@ static uint8 regs[4]; static uint8 hrd_flag; -static void(*Sync)(void); static SFORMAT StateRegs[] = { @@ -34,7 +33,8 @@ static SFORMAT StateRegs[] = { 0 } }; -static void SyncAbG1l(void) { +static void Sync(void) { + int mask = regs[2] >> 6; /* There is an CNROM mode that takes either two or four inner CHR banks from a CNROM-like latch register at $8000-$FFFF. */ if (regs[1] & 0x10) setprg32(0x8000,(regs[1] & 0xC0) >> 6); @@ -44,48 +44,36 @@ static void SyncAbG1l(void) { setprg16(0xC000, (regs[1] & 0xE0) >> 5); } - /* FIXME: 2020-10-26 */ - switch (regs[2] & 0xC0) { - case 0xC0: /* Pipe Dream */ - setchr8((regs[0] & 0x03) | (regs[1] & ~0x03)); - break; - case 0x40: /* Goonies */ - setchr8((regs[0] & 0x01) | (regs[1] & 0x07)); - break; - default: - setchr8(regs[1]); - break; - } - + setchr8(((regs[1] & 0x07) & ~mask) | regs[0] & mask); + setmirror((regs[1] & 0x8) ? 0 : 1); } -static DECLFW(AbG1lWriteHi) { +static DECLFW(WriteHi) { regs[0] = V; - /* setchr8(((regs[2] & 0xC0) >> 7) << 2 | (regs[0] & 0x03)); */ Sync(); } -static DECLFW(AbG1lWriteLo) { +static DECLFW(WriteLo) { regs[A & 0x03] = V; Sync(); } -static DECLFR(AbG1lReadLo) { +static DECLFR(ReadLo) { return hrd_flag; } -static void AbG1lPower(void) { - hrd_flag = 0; +static void Power(void) { + hrd_flag = 0; /* Solder pad, selecting different menus */ regs[0] = 0; regs[1] = 0; regs[2] = 0; Sync(); - SetWriteHandler(0x8000, 0xFFFF, AbG1lWriteHi); - SetWriteHandler(0x6001, 0x6002, AbG1lWriteLo); - SetReadHandler(0x6000, 0x7FFF, AbG1lReadLo); + SetWriteHandler(0x8000, 0xFFFF, WriteHi); + SetWriteHandler(0x6001, 0x6002, WriteLo); + SetReadHandler(0x6000, 0x7FFF, ReadLo); SetReadHandler(0x8000, 0xFFFF, CartBR); } @@ -93,7 +81,7 @@ static void StateRestore(int version) { Sync(); } -static void AbG1lReset(void) { +static void Reset(void) { hrd_flag++; hrd_flag &= 3; @@ -104,64 +92,14 @@ static void AbG1lReset(void) { Sync(); } -void AbG1l_Init(CartInfo *info) { - - Sync = SyncAbG1l; - +void Mapper428_Init(CartInfo *info) { hrd_flag = 0; Sync(); - info->Power = AbG1lPower; - info->Reset = AbG1lReset; + info->Power = Power; + info->Reset = Reset; AddExState(&StateRegs, ~0, 0, 0); GameStateRestore = StateRestore; } - -static void SyncWellNoDG450(void) { - - if (regs[1] & 0x10) - setprg32(0x8000, (regs[1]) >> 6); - else - { - setprg16(0x8000, (regs[1]) >> 5); - setprg16(0xC000, (regs[1]) >> 5); - } - - setchr8(regs[1] & 0x0F); - setmirror((regs[1] & 0x8) ? 0 : 1); -} - -static void WellNoDG450Power(void) { - hrd_flag = 0; - - regs[0] = 0; - regs[1] = 0; - regs[2] = 0; - - Sync(); - - SetWriteHandler(0x6001, 0x6002, AbG1lWriteLo); - SetReadHandler(0x6000, 0x7FFF, AbG1lReadLo); - SetReadHandler(0x8000, 0xFFFF, CartBR); -} - -static void WellNoDG450Reset(void) { - hrd_flag++; - hrd_flag &= 3; - - regs[0] = 0; - regs[1] = 0; - regs[2] = 0; - - Sync(); -} - -void WellNoDG450_Init(CartInfo *info) { - Sync = SyncWellNoDG450; - info->Power = WellNoDG450Power; - info->Reset = WellNoDG450Reset; - AddExState(&StateRegs, ~0, 0, 0); - GameStateRestore = StateRestore; -} diff --git a/src/ines.c b/src/ines.c index 33cbed2..ce9e8b3 100644 --- a/src/ines.c +++ b/src/ines.c @@ -788,6 +788,7 @@ INES_BOARD_BEGIN() INES_BOARD( "YY850439C", 397, Mapper397_Init ) INES_BOARD( "831019C J-2282", 402, J2282_Init ) INES_BOARD( "SC871115C", 421, Mapper421_Init ) + INES_BOARD( "AB-G1L/WELL-NO-DG450", 428, Mapper428_Init ) INES_BOARD( "SA-9602B", 513, SA9602B_Init ) INES_BOARD( "DANCE2000", 518, UNLD2000_Init ) INES_BOARD( "EH8813A", 519, UNLEH8813A_Init ) diff --git a/src/ines.h b/src/ines.h index cbeaf42..ad0556e 100644 --- a/src/ines.h +++ b/src/ines.h @@ -282,6 +282,7 @@ void Mapper401_Init(CartInfo *); void Mapper411_Init(CartInfo *); void Mapper421_Init(CartInfo *); void Mapper422_Init(CartInfo *); +void Mapper428_Init(CartInfo *); void Mapper516_Init(CartInfo *); void Mapper533_Init(CartInfo *); void Mapper534_Init(CartInfo *); diff --git a/src/unif.c b/src/unif.c index 14c3f60..e69a75a 100644 --- a/src/unif.c +++ b/src/unif.c @@ -438,7 +438,7 @@ static BMAPPING bmap[] = { { "8237A", 215, UNL8237A_Init, 0 }, { "830118C", 348, BMC830118C_Init, 0 }, { "A65AS", 285, BMCA65AS_Init, 0 }, - { "AB-G1L", NO_INES, AbG1l_Init, 0 }, + { "AB-G1L", 428, Mapper428_Init, 0 }, { "AC08", 42, AC08_Init, 0 }, { "ANROM", 7, ANROM_Init, 0 }, { "AX5705", 530, UNLAX5705_Init, 0 }, @@ -559,7 +559,8 @@ static BMAPPING bmap[] = { { "UNROM-512-32", 30, UNROM512_Init, BMCFLAG_32KCHRR }, { "UOROM", 2, UNROM_Init, 0 }, { "VRC7", 85, UNLVRC7_Init, 0 }, - { "WELL-NO-DG450", NO_INES, WellNoDG450_Init, 0 }, + { "WELL-NO-DG450", 428, Mapper428_Init, 0 }, + { "TF2740", 428, Mapper428_Init, 0 }, { "YOKO", 264, UNLYOKO_Init, 0 }, { "COOLBOY", 268, COOLBOY_Init, BMCFLAG_256KCHRR }, { "158B", 258, UNL158B_Init, 0 }, diff --git a/src/unif.h b/src/unif.h index 4f5517e..c53a3e8 100644 --- a/src/unif.h +++ b/src/unif.h @@ -189,8 +189,6 @@ void BMC830134C_Init(CartInfo *info); /* m315 */ void BMCGN26_Init(CartInfo *info); /* m344 */ void BS110_Init(CartInfo *info); -void WellNoDG450_Init(CartInfo *info); -void AbG1l_Init(CartInfo *info); void KG256_Init(CartInfo *info); void WAIXINGFS005_Init(CartInfo *info);