diff --git a/src/boards/158B.c b/src/boards/158B.c deleted file mode 100644 index 8bd0f5d..0000000 --- a/src/boards/158B.c +++ /dev/null @@ -1,71 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2015 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * "Blood Of Jurassic" protected MMC3 based board (GD-98 Cart ID, 158B PCB ID) - * - */ - -#include "mapinc.h" -#include "mmc3.h" - -static uint8 lut[8] = { 0x00, 0x00, 0x00, 0x01, 0x02, 0x04, 0x0F, 0x00 }; - -static void UNL158BPW(uint32 A, uint8 V) { - if (EXPREGS[0] & 0x80) { - uint32 bank = EXPREGS[0] & 7; - if(EXPREGS[0] & 0x20) { /* 32Kb mode */ - setprg32(0x8000, bank >> 1); - } else { /* 16Kb mode */ - setprg16(0x8000, bank); - setprg16(0xC000, bank); - } - } else { - setprg8(A, V & 0xF); - } -} - -static DECLFW(UNL158BProtWrite) { - EXPREGS[A & 7] = V; - switch(A & 7) { - case 0: - FixMMC3PRG(MMC3_cmd); - break; - case 7: - FCEU_printf("UNK PROT WRITE\n"); - break; - } - -} - -static DECLFR(UNL158BProtRead) { - return X.DB | lut[A & 7]; -} - -static void UNL158BPower(void) { - GenMMC3Power(); - SetWriteHandler(0x5000, 0x5FFF, UNL158BProtWrite); - SetReadHandler(0x5000, 0x5FFF, UNL158BProtRead); -} - -void UNL158B_Init(CartInfo *info) { - GenMMC3_Init(info, 128, 128, 0, 0); - pwrap = UNL158BPW; - info->Power = UNL158BPower; - AddExState(EXPREGS, 8, 0, "EXPR"); -} diff --git a/src/boards/8237.c b/src/boards/8237.c index 4c5b869..c72d969 100644 --- a/src/boards/8237.c +++ b/src/boards/8237.c @@ -63,6 +63,17 @@ static uint8 adrperm[8][8] = { 0, 1, 2, 3, 4, 5, 6, 7 }, /* empty */ }; +static uint8 protarray[8][8] = { + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, /* 0 Super Hang-On */ + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00 }, /* 1 Monkey King */ + { 0x00, 0x00, 0x00, 0x00, 0x03, 0x04, 0x00, 0x00 }, /* 2 Super Hang-On/Monkey King */ + { 0x00, 0x00, 0x00, 0x01, 0x00, 0x04, 0x05, 0x00 }, /* 3 Super Hang-On/Monkey King */ + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, /* 4 */ + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, /* 5 */ + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, /* 6 */ + { 0x00, 0x00, 0x00, 0x01, 0x02, 0x04, 0x0F, 0x00 } /* 7 (default) Blood of Jurassic */ +}; + static void UNL8237CW(uint32 A, uint8 V) { uint16 outer_bank; @@ -109,6 +120,10 @@ static void UNL8237PW(uint32 A, uint8 V) { } } +static DECLFR(UNL8237ProtRead) { + return protarray[EXPREGS[3]][A &7] &0x0F | 0x50; +} + static DECLFW(UNL8237Write) { uint8 dat = V; uint8 adr = adrperm[EXPREGS[2]][((A >> 12) & 6) | (A & 1)]; @@ -125,6 +140,7 @@ static DECLFW(UNL8237ExWrite) { switch (A & 0xF007) { case 0x5000: EXPREGS[0] = V; FixMMC3PRG(MMC3_cmd); FixMMC3CHR(MMC3_cmd); break; case 0x5001: EXPREGS[1] = V; FixMMC3PRG(MMC3_cmd); FixMMC3CHR(MMC3_cmd); break; + case 0x5002: EXPREGS[3] = V; break; case 0x5007: EXPREGS[2] = V; break; } } @@ -132,9 +148,18 @@ static DECLFW(UNL8237ExWrite) { static void UNL8237Power(void) { EXPREGS[0] = EXPREGS[2] = 0; EXPREGS[1] = 0x0F; + EXPREGS[3] = 7; GenMMC3Power(); SetWriteHandler(0x8000, 0xFFFF, UNL8237Write); - SetWriteHandler(0x5000, 0x7FFF, UNL8237ExWrite); + SetReadHandler (0x5000, 0x5FFF, UNL8237ProtRead); + SetWriteHandler(0x5000, 0x5FFF, UNL8237ExWrite); +} + +static void UNL8237Reset(void) { + EXPREGS[0] = EXPREGS[2] = 0; + EXPREGS[1] = 0x0F; + EXPREGS[3] = 7; + MMC3RegReset(); } void UNL8237_Init(CartInfo *info) { @@ -142,8 +167,8 @@ void UNL8237_Init(CartInfo *info) { cwrap = UNL8237CW; pwrap = UNL8237PW; info->Power = UNL8237Power; - AddExState(EXPREGS, 3, 0, "EXPR"); - AddExState(&submapper, 1, 0, "SUBM"); + info->Reset = UNL8237Reset; + AddExState(EXPREGS, 4, 0, "EXPR"); if (info->iNES2) submapper = info->submapper; } diff --git a/src/ines-correct.h b/src/ines-correct.h index fb80e15..18f251d 100644 --- a/src/ines-correct.h +++ b/src/ines-correct.h @@ -913,12 +913,14 @@ { 0x6e149729, 189, DEFAULT, DEFAULT, 0, DEFAULT, DEFAULT, DEFAULT, NOEXTRA }, /* Master Fighter II (Unl) [a1].nes */ { 0x60bfeb0c, 90, DEFAULT, DEFAULT, 0, DEFAULT, DEFAULT, DEFAULT, NOEXTRA }, /* Mortal Kombat 2 (Unl) [!].nes */ { 0x247cc73d, 150, DEFAULT, DEFAULT, 0, DEFAULT, DEFAULT, DEFAULT, NOEXTRA }, /* Poker II (Asia) (Ja) (Unl).nes */ - { 0x1f1326d4, 121, DEFAULT, MI_H, 0, DEFAULT, DEFAULT, DEFAULT, NOEXTRA }, /* Super Sonic 5 (1997) (Unl) [!].nes */ - { 0x99748230, 215, DEFAULT, MI_H, 0, DEFAULT, DEFAULT, DEFAULT, NOEXTRA }, /* EarthWorm Jim 2 (SuperGame).nes */ - { 0x37876ac7, 215, DEFAULT, MI_H, 0, DEFAULT, DEFAULT, DEFAULT, NOEXTRA }, /* Golden Card 6-in-1 (Unl) [!].nes */ - { 0x1a3320a3, 215, DEFAULT, MI_H, 0, DEFAULT, DEFAULT, DEFAULT, NOEXTRA }, /* Mortal Kombat 3 (SuperGame).nes */ - { 0x80eb1839, 114, DEFAULT, MI_H, 0, DEFAULT, DEFAULT, DEFAULT, NOEXTRA }, /* Boogerman (Sugar Softec) (Unl) [!].nes */ - { 0x071e4ee8, 114, DEFAULT, MI_H, 0, DEFAULT, DEFAULT, DEFAULT, NOEXTRA }, /* ?? m114,submapper 1 test rom */ + { 0x1f1326d4, 121, DEFAULT, DEFAULT, 0, DEFAULT, DEFAULT, DEFAULT, NOEXTRA }, /* Super Sonic 5 (1997) (Unl) [!].nes */ + { 0x99748230, 215, DEFAULT, DEFAULT, 0, DEFAULT, DEFAULT, DEFAULT, NOEXTRA }, /* EarthWorm Jim 2 (SuperGame).nes */ + { 0x37876ac7, 215, DEFAULT, DEFAULT, 0, DEFAULT, DEFAULT, DEFAULT, NOEXTRA }, /* Golden Card 6-in-1 (Unl) [!].nes */ + { 0x1a3320a3, 215, DEFAULT, DEFAULT, 0, DEFAULT, DEFAULT, DEFAULT, NOEXTRA }, /* Mortal Kombat 3 (SuperGame).nes */ + { 0xec70f8d8, 258, DEFAULT, DEFAULT, 0, DEFAULT, DEFAULT, DEFAULT, NOEXTRA }, /* 1997 留念: 港-京 - Super Hang-On (protected version, CHR doubled) */ + { 0x224989d9, 258, DEFAULT, DEFAULT, 0, DEFAULT, DEFAULT, DEFAULT, NOEXTRA }, /* 1997 留念: 港-京 - Super Hang-On (protected version) */ + { 0x80eb1839, 114, 1, DEFAULT, 0, DEFAULT, DEFAULT, DEFAULT, NOEXTRA }, /* Boogerman (Sugar Softec) (Unl) [!].nes */ + { 0x071e4ee8, 114, DEFAULT, DEFAULT, 0, DEFAULT, DEFAULT, DEFAULT, NOEXTRA }, /* ?? m114,submapper 1 test rom */ { 0xfe3e03a1, 197, DEFAULT, DEFAULT, 0, DEFAULT, DEFAULT, DEFAULT, NOEXTRA }, /* Mortal Kombat III Special (YY-030) (Ch) [!].nes */ { 0x9151d311, 197, DEFAULT, DEFAULT, 0, DEFAULT, DEFAULT, DEFAULT, NOEXTRA }, /* Mortal Kombat III 28 Peoples (NT-328) (Ch) [!].nes */ { 0x272709b9, 237, DEFAULT, DEFAULT, 0, DEFAULT, DEFAULT, DEFAULT, NOEXTRA }, /* Teletubbies Y2K (420-in-1).nes */ diff --git a/src/ines.c b/src/ines.c index ac867b1..f2af9d5 100644 --- a/src/ines.c +++ b/src/ines.c @@ -679,7 +679,7 @@ INES_BOARD_BEGIN() /* NES 2.0 MAPPERS */ INES_BOARD( "OneBus", 256, UNLOneBus_Init ) - INES_BOARD( "158B", 258, UNL158B_Init ) + INES_BOARD( "158B", 258, UNL8237_Init ) INES_BOARD( "F-15", 259, BMCF15_Init ) INES_BOARD( "HPxx / HP2018-A", 260, BMCHPxx_Init ) INES_BOARD( "810544-C-A1", 261, BMC810544CA1_Init ) diff --git a/src/unif.c b/src/unif.c index 44f065b..7ee2e29 100644 --- a/src/unif.c +++ b/src/unif.c @@ -565,7 +565,7 @@ static BMAPPING bmap[] = { { "YOKO", 264, UNLYOKO_Init, 0 }, { "COOLBOY", 268, COOLBOY_Init, BMCFLAG_256KCHRR }, { "MINDKIDS", 268, MINDKIDS_Init, BMCFLAG_256KCHRR }, - { "158B", 258, UNL158B_Init, 0 }, + { "158B", 258, UNL8237_Init, 0 }, { "DRAGONFIGHTER", 292, UNLBMW8544_Init, 0 }, { "EH8813A", 519, UNLEH8813A_Init, 0 }, { "HP898F", 319, BMCHP898F_Init, 0 }, diff --git a/src/unif.h b/src/unif.h index a0826ff..351765c 100644 --- a/src/unif.h +++ b/src/unif.h @@ -139,7 +139,6 @@ void UNLYOKO_Init(CartInfo *info); void UNROM_Init(CartInfo *info); void UNROM512_Init(CartInfo *info); void COOLBOY_Init(CartInfo *info); -void UNL158B_Init(CartInfo *info); void UNLBMW8544_Init(CartInfo *info); void UNLEH8813A_Init(CartInfo *info); void BMCHP898F_Init(CartInfo *info);