diff --git a/src/boards/mmc1.c b/src/boards/mmc1.c index fd6ca8c..a3f670d 100644 --- a/src/boards/mmc1.c +++ b/src/boards/mmc1.c @@ -468,4 +468,67 @@ void Mapper374_Init(CartInfo *info) { MMC1PRGHook16 = M374PRG; info->Reset = M374Reset; AddExState(&game, 1, 0, "GAME"); -} \ No newline at end of file +} + +/* ---------------------------- Mapper 297 -------------------------------- */ +/* NES 2.0 Mapper 297 - 2-in-1 Uzi Lightgun (MGC-002) */ + +static uint8 mode; +static uint8 latch; + +static void M297PRG(uint32 A, uint8 V) { + setprg16(A, (V & 0x07) | ((mode & 1) << 3)); +} + +static void M297CHR(uint32 A, uint8 V) { + setchr4(A, (V & 0x1F) | ((mode & 1) << 5)); +} + +static void Sync(void) { + if (mode & 1) { + /* MMC1 */ + MMC1PRG(); + MMC1CHR(); + MMC1MIRROR(); + } else { + /* Mapper 70 */ + setprg16(0x8000, ((mode & 2) << 1) | ((latch >> 4) & 3)); + setprg16(0xC000, ((mode & 2) << 1) | 3); + setchr8(latch & 0xF); + setmirror(1); + } +} + +static DECLFW(M297Mode) { + if (A & 0x100) { + mode = V; + Sync(); + } +} + +static DECLFW(M297Latch) { + if (mode & 1) { + MMC1_write(A, V); + } else { + latch = V; + Sync(); + } +} + +static void M297Power(void) { + latch = 0; + mode = 0; + Sync(); + GenMMC1Power(); + SetWriteHandler(0x4120, 0x4120, M297Mode); + SetWriteHandler(0x8000, 0xFFFF, M297Latch); +} + +void Mapper297_Init(CartInfo *info) { + GenMMC1Init(info, 256, 256, 0, 0); + info->Power = M297Power; + MMC1CHRHook4 = M297CHR; + MMC1PRGHook16 = M297PRG; + AddExState(&latch, 1, 0, "LATC"); + AddExState(&mode, 1, 0, "MODE"); +} diff --git a/src/ines.c b/src/ines.c index 6900951..8b52604 100644 --- a/src/ines.c +++ b/src/ines.c @@ -198,6 +198,8 @@ static void SetInput(void) { {0xb8b9aca3, SI_UNSET, SI_ZAPPER, SIFC_NONE }, /* Wild Gunman */ {0x5112dc21, SI_UNSET, SI_ZAPPER, SIFC_NONE }, /* Wild Gunman */ {0xaf4010ea, SI_GAMEPAD, SI_POWERPADB, SIFC_UNSET }, /* World Class Track Meet */ + {0xb3cc4d26, SI_GAMEPAD, SI_UNSET, SIFC_SHADOW }, /* 2-in-1 Uzi Lightgun (MGC-002) */ + {0x00000000, SI_UNSET, SI_UNSET, SIFC_UNSET } }; int x = 0; @@ -670,6 +672,7 @@ static BMAPPINGLocal bmap[] = { {(uint8_t*)"LittleCom 160-in-1", 541, Mapper541_Init }, {(uint8_t*)"8-in-1 JY-119", 267, Mapper267_Init }, {(uint8_t*)"MMC3 BMC PIRATE", 294, Bs5652_Init}, /* nesdev redirects this as mapper 134 */ + {(uint8_t*)"TXC 01-22110-000", 297, Mapper297_Init}, /* UNIF to NES 2.0 BOARDS */ diff --git a/src/ines.h b/src/ines.h index c8bc211..871216d 100644 --- a/src/ines.h +++ b/src/ines.h @@ -245,6 +245,7 @@ void J2282_Init(CartInfo *); void Mapper267_Init(CartInfo *); void Mapper288_Init(CartInfo *); +void Mapper297_Init(CartInfo *); void Mapper357_Init(CartInfo *); void Mapper372_Init(CartInfo *); void Mapper374_Init(CartInfo *);