From 33ae3916b20762aef1281a48f4f0bfd4a948ecdc Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Wed, 11 Mar 2020 19:03:46 +0800 Subject: [PATCH] ines.c: Cleanup mapper struct and iNESLoad() - cleaned and sorted the nes mapper index struct - move items around in iNESLoad() and use CartInfo struct where applicable - other minor cleanups --- src/ines.c | 1074 +++++++++++++++++++++++++++------------------------- 1 file changed, 549 insertions(+), 525 deletions(-) diff --git a/src/ines.c b/src/ines.c index 20f73a1..197dfd4 100644 --- a/src/ines.c +++ b/src/ines.c @@ -42,25 +42,21 @@ extern SFORMAT FCEUVSUNI_STATEINFO[]; -uint8 *trainerpoo = NULL; -uint8 *ROM = NULL; -uint8 *VROM = NULL; -uint8 *ExtraNTARAM = NULL; -iNES_HEADER head; +uint8 *trainerpoo = NULL; +uint8 *ROM = NULL; +uint8 *VROM = NULL; +uint8 *ExtraNTARAM = NULL; +iNES_HEADER head = {0}; -CartInfo iNESCart; +CartInfo iNESCart = {0}; -uint8 Mirroring = 0; -uint32 ROM_size = 0; -uint32 VROM_size = 0; +uint32 ROM_size = 0; +uint32 VROM_size = 0; + +static int CHRRAMSize = -1; -static int CHRRAMSize = -1; static int iNES_Init(int num); -static int iNES2 = 0; -static int MapperNo = 0; -static int subMapper = 0; - static DECLFR(TrainerRead) { return(trainerpoo[A & 0x1FF]); } @@ -82,36 +78,36 @@ static void iNES_ExecPower() { } static void iNESGI(int h) { - switch (h) - { - case GI_RESETM2: - if (iNESCart.Reset) - iNESCart.Reset(); - break; - case GI_POWER: - iNES_ExecPower(); - break; - case GI_CLOSE: - if (iNESCart.Close) - iNESCart.Close(); - if (ROM) { - free(ROM); - ROM = NULL; - } - if (VROM) { - free(VROM); - VROM = NULL; - } - if (trainerpoo) { - free(trainerpoo); - trainerpoo = NULL; - } - if (ExtraNTARAM) { - free(ExtraNTARAM); - ExtraNTARAM = NULL; - } - break; - } + switch (h) + { + case GI_RESETM2: + if (iNESCart.Reset) + iNESCart.Reset(); + break; + case GI_POWER: + iNES_ExecPower(); + break; + case GI_CLOSE: + if (iNESCart.Close) + iNESCart.Close(); + if (ROM) { + free(ROM); + ROM = NULL; + } + if (VROM) { + free(VROM); + VROM = NULL; + } + if (trainerpoo) { + free(trainerpoo); + trainerpoo = NULL; + } + if (ExtraNTARAM) { + free(ExtraNTARAM); + ExtraNTARAM = NULL; + } + break; + } } struct CRCMATCH { @@ -313,27 +309,27 @@ static void CheckHInfo(void) { VROM = NULL; tofix |= 8; } - if (MapperNo != (moo[x].mapper & 0xFFF)) { + if (iNESCart.mapper != (moo[x].mapper & 0xFFF)) { tofix |= 1; - current_mapper = MapperNo; - MapperNo = moo[x].mapper & 0xFFF; + current_mapper = iNESCart.mapper; + iNESCart.mapper = moo[x].mapper & 0xFFF; } } if (moo[x].mirror >= 0) { - cur_mirr = Mirroring; + cur_mirr = iNESCart.mirror; if (moo[x].mirror == 8) { - if (Mirroring == 2) { /* Anything but hard-wired(four screen). */ + if (iNESCart.mirror == 2) { /* Anything but hard-wired(four screen). */ tofix |= 2; - Mirroring = 0; + iNESCart.mirror = 0; } - } else if (Mirroring != moo[x].mirror) { - if (Mirroring != (moo[x].mirror & ~4)) + } else if (iNESCart.mirror != moo[x].mirror) { + if (iNESCart.mirror != (moo[x].mirror & ~4)) if ((moo[x].mirror & ~4) <= 2) /* Don't complain if one-screen mirroring needs to be set(the iNES header can't hold this information). */ tofix |= 2; - Mirroring = moo[x].mirror; + iNESCart.mirror = moo[x].mirror; } } break; @@ -355,29 +351,30 @@ static void CheckHInfo(void) { /* Games that use these iNES mappers tend to have the four-screen bit set when it should not be. */ - if ((MapperNo == 118 || MapperNo == 24 || MapperNo == 26) && (Mirroring == 2)) { - Mirroring = 0; + if ((iNESCart.mapper == 118 || iNESCart.mapper == 24 || iNESCart.mapper == 26) && (iNESCart.mirror == 2)) { + iNESCart.mirror = 0; tofix |= 2; } /* Four-screen mirroring implicitly set. */ - if (MapperNo == 99) - Mirroring = 2; + if (iNESCart.mapper == 99) + iNESCart.mirror = 2; if (tofix) { char gigastr[768]; - strcpy(gigastr, "The iNES header contains incorrect information. For now, the information will be corrected in RAM. "); + strcpy(gigastr, " The iNES header contains incorrect information. For now, the information will be corrected in RAM. "); if (tofix & 1) - sprintf(gigastr + strlen(gigastr), "Current mapper # is %d. The mapper number should be set to %d. ", current_mapper, MapperNo); + sprintf(gigastr + strlen(gigastr), "Current mapper # is %d. The mapper number should be set to %d. ", current_mapper, iNESCart.mapper); if (tofix & 2) { uint8 *mstr[3] = { (uint8_t*)"Horizontal", (uint8_t*)"Vertical", (uint8_t*)"Four-screen" }; - sprintf(gigastr + strlen(gigastr), "Current mirroring is %s. Mirroring should be set to \"%s\". ", mstr[cur_mirr & 3], mstr[Mirroring & 3]); + sprintf(gigastr + strlen(gigastr), "Current mirroring is %s. Mirroring should be set to \"%s\". ", mstr[cur_mirr & 3], mstr[iNESCart.mirror & 3]); } if (tofix & 4) strcat(gigastr, "The battery-backed bit should be set. "); if (tofix & 8) strcat(gigastr, "This game should not have any CHR ROM. "); strcat(gigastr, "\n"); + FCEU_printf("\n", gigastr); FCEU_printf("%s\n", gigastr); } } @@ -393,394 +390,440 @@ typedef struct { void (*init)(CartInfo *); } BMAPPINGLocal; -static BMAPPINGLocal bmap[] = { - {(uint8_t*)"NROM", 0, NROM_Init}, - {(uint8_t*)"MMC1", 1, Mapper1_Init}, - {(uint8_t*)"UNROM", 2, UNROM_Init}, - {(uint8_t*)"CNROM", 3, CNROM_Init}, - {(uint8_t*)"MMC3", 4, Mapper4_Init}, - {(uint8_t*)"MMC5", 5, Mapper5_Init}, - {(uint8_t*)"FFE Rev. A", 6, Mapper6_Init}, - {(uint8_t*)"ANROM", 7, ANROM_Init}, - {(uint8_t*)"", 8, Mapper8_Init}, /* Nogaems, it's worthless */ - {(uint8_t*)"MMC2", 9, Mapper9_Init}, - {(uint8_t*)"MMC4", 10, Mapper10_Init}, - {(uint8_t*)"Color Dreams", 11, Mapper11_Init}, - {(uint8_t*)"REX DBZ 5", 12, Mapper12_Init}, - {(uint8_t*)"CPROM", 13, CPROM_Init}, - {(uint8_t*)"REX SL-1632", 14, UNLSL1632_Init}, - {(uint8_t*)"100-in-1", 15, Mapper15_Init}, - {(uint8_t*)"BANDAI 24C02", 16, Mapper16_Init}, - {(uint8_t*)"FFE Rev. B", 17, Mapper17_Init}, - {(uint8_t*)"JALECO SS880006", 18, Mapper18_Init}, /* JF-NNX (EB89018-30007) boards */ - {(uint8_t*)"Namcot 106", 19, Mapper19_Init}, -/* {(uint8_t*)"", 20, Mapper20_Init}, */ - {(uint8_t*)"Konami VRC2/VRC4 A", 21, Mapper21_Init}, - {(uint8_t*)"Konami VRC2/VRC4 B", 22, Mapper22_Init}, - {(uint8_t*)"Konami VRC2/VRC4 C", 23, Mapper23_Init}, - {(uint8_t*)"Konami VRC6 Rev. A", 24, Mapper24_Init}, - {(uint8_t*)"Konami VRC2/VRC4 D", 25, Mapper25_Init}, - {(uint8_t*)"Konami VRC6 Rev. B", 26, Mapper26_Init}, - {(uint8_t*)"CC-21 MI HUN CHE", 27, UNLCC21_Init}, /* Former dupe for VRC2/VRC4 mapper, redefined with crc to mihunche boards */ - {(uint8_t*)"Action 53", 28, Mapper28_Init}, - {(uint8_t*)"", 29, Mapper29_Init}, - {(uint8_t*)"UNROM 512", 30, UNROM512_Init}, - {(uint8_t*)"infineteNesLives-NSF", 31, Mapper31_Init}, - {(uint8_t*)"IREM G-101", 32, Mapper32_Init}, - {(uint8_t*)"TC0190FMC/TC0350FMR", 33, Mapper33_Init}, - {(uint8_t*)"IREM I-IM/BNROM", 34, Mapper34_Init}, - {(uint8_t*)"Wario Land 2", 35, UNLSC127_Init}, - {(uint8_t*)"TXC Policeman", 36, Mapper36_Init}, - {(uint8_t*)"PAL-ZZ SMB/TETRIS/NWC",37, Mapper37_Init}, - {(uint8_t*)"Bit Corp.", 38, Mapper38_Init}, /* Crime Busters */ -/* {(uint8_t*)"", 39, Mapper39_Init}, */ - {(uint8_t*)"SMB2j FDS", 40, Mapper40_Init}, - {(uint8_t*)"CALTRON 6-in-1", 41, Mapper41_Init}, - {(uint8_t*)"BIO MIRACLE FDS", 42, Mapper42_Init}, - {(uint8_t*)"FDS SMB2j LF36", 43, Mapper43_Init}, - {(uint8_t*)"MMC3 BMC PIRATE A", 44, Mapper44_Init}, - {(uint8_t*)"MMC3 BMC PIRATE B", 45, Mapper45_Init}, - {(uint8_t*)"RUMBLESTATION 15-in-1",46, Mapper46_Init}, - {(uint8_t*)"NES-QJ SSVB/NWC", 47, Mapper47_Init}, - {(uint8_t*)"TAITO TCxxx", 48, Mapper48_Init}, - {(uint8_t*)"MMC3 BMC PIRATE C", 49, Mapper49_Init}, - {(uint8_t*)"SMB2j FDS Rev. A", 50, Mapper50_Init}, - {(uint8_t*)"11-in-1 BALL SERIES", 51, Mapper51_Init}, /* 1993 year version */ - {(uint8_t*)"MMC3 BMC PIRATE D", 52, Mapper52_Init}, - {(uint8_t*)"SUPERVISION 16-in-1", 53, Supervision16_Init}, -/* {(uint8_t*)"", 54, Mapper54_Init}, */ -/* {(uint8_t*)"", 55, Mapper55_Init}, */ - {(uint8_t*)"UNLKS202", 56, UNLKS202_Init}, - {(uint8_t*)"SIMBPLE BMC PIRATE A", 57, Mapper57_Init}, - {(uint8_t*)"SIMBPLE BMC PIRATE B", 58, BMCGK192_Init}, - {(uint8_t*)"", 59, Mapper59_Init}, /* Check this out */ - {(uint8_t*)"SIMBPLE BMC PIRATE C", 60, BMCD1038_Init}, - {(uint8_t*)"20-in-1 KAISER Rev. A",61, Mapper61_Init}, - {(uint8_t*)"700-in-1", 62, Mapper62_Init}, - {(uint8_t*)"", 63, Mapper63_Init}, - {(uint8_t*)"TENGEN RAMBO1", 64, Mapper64_Init}, - {(uint8_t*)"IREM-H3001", 65, Mapper65_Init}, - {(uint8_t*)"MHROM", 66, MHROM_Init}, - {(uint8_t*)"SUNSOFT-FZII", 67, Mapper67_Init}, - {(uint8_t*)"Sunsoft Mapper #4", 68, Mapper68_Init}, - {(uint8_t*)"SUNSOFT-5/FME-7", 69, Mapper69_Init}, - {(uint8_t*)"BA KAMEN DISCRETE", 70, Mapper70_Init}, - {(uint8_t*)"CAMERICA BF9093", 71, Mapper71_Init}, - {(uint8_t*)"JALECO JF-17", 72, Mapper72_Init}, - {(uint8_t*)"KONAMI VRC3", 73, Mapper73_Init}, - {(uint8_t*)"TW MMC3+VRAM Rev. A", 74, Mapper74_Init}, - {(uint8_t*)"KONAMI VRC1", 75, Mapper75_Init}, - {(uint8_t*)"NAMCOT 108 Rev. A", 76, Mapper76_Init}, - {(uint8_t*)"IREM LROG017", 77, Mapper77_Init}, - {(uint8_t*)"Irem 74HC161/32", 78, Mapper78_Init}, - {(uint8_t*)"AVE/C&E/TXC BOARD", 79, Mapper79_Init}, - {(uint8_t*)"TAITO X1-005 Rev. A", 80, Mapper80_Init}, -/* {(uint8_t*)"", 81, Mapper81_Init}, */ - {(uint8_t*)"TAITO X1-017", 82, Mapper82_Init}, - {(uint8_t*)"YOKO VRC Rev. B", 83, Mapper83_Init}, -/* {(uint8_t*)"", 84, Mapper84_Init}, */ - {(uint8_t*)"KONAMI VRC7", 85, Mapper85_Init}, - {(uint8_t*)"JALECO JF-13", 86, Mapper86_Init}, - {(uint8_t*)"74*139/74 DISCRETE", 87, Mapper87_Init}, - {(uint8_t*)"NAMCO 3433", 88, Mapper88_Init}, - {(uint8_t*)"SUNSOFT-3", 89, Mapper89_Init}, /* SUNSOFT-2 mapper */ - {(uint8_t*)"HUMMER/JY BOARD", 90, Mapper90_Init}, - {(uint8_t*)"EARLY HUMMER/JY BOARD",91, Mapper91_Init}, - {(uint8_t*)"JALECO JF-19", 92, Mapper92_Init}, - {(uint8_t*)"SUNSOFT-3R", 93, SUNSOFT_UNROM_Init},/* SUNSOFT-2 mapper with VRAM, different wiring */ - {(uint8_t*)"HVC-UN1ROM", 94, Mapper94_Init}, - {(uint8_t*)"NAMCOT 108 Rev. B", 95, Mapper95_Init}, - {(uint8_t*)"BANDAI OEKAKIDS", 96, Mapper96_Init}, - {(uint8_t*)"IREM TAM-S1", 97, Mapper97_Init}, -/* {(uint8_t*)"", 98, Mapper98_Init}, */ - {(uint8_t*)"VS Uni/Dual- system", 99, Mapper99_Init}, -/* {(uint8_t*)"", 100, Mapper100_Init}, */ - {(uint8_t*)"", 101, Mapper101_Init}, -/* {(uint8_t*)"", 102, Mapper102_Init}, */ - {(uint8_t*)"FDS DOKIDOKI FULL", 103, Mapper103_Init}, - {(uint8_t*)"CAMERICA GOLDENFIVE", 104, Mapper104_Init}, - {(uint8_t*)"NES-EVENT NWC1990", 105, Mapper105_Init}, - {(uint8_t*)"SMB3 PIRATE A", 106, Mapper106_Init}, - {(uint8_t*)"MAGIC CORP A", 107, Mapper107_Init}, - {(uint8_t*)"FDS UNROM BOARD", 108, Mapper108_Init}, -/* {(uint8_t*)"", 109, Mapper109_Init}, */ -/* {(uint8_t*)"", 110, Mapper110_Init}, */ - {(uint8_t*)"Cheapocabra", 111, Mapper111_Init}, - {(uint8_t*)"ASDER/NTDEC BOARD", 112, Mapper112_Init}, - {(uint8_t*)"HACKER/SACHEN BOARD", 113, Mapper113_Init}, - {(uint8_t*)"MMC3 SG PROT. A", 114, Mapper114_Init}, - {(uint8_t*)"MMC3 PIRATE A", 115, Mapper115_Init}, - {(uint8_t*)"MMC1/MMC3/VRC PIRATE",116, UNLSL12_Init}, - {(uint8_t*)"FUTURE MEDIA BOARD", 117, Mapper117_Init}, - {(uint8_t*)"TSKROM", 118, TKSROM_Init}, - {(uint8_t*)"NES-TQROM", 119, Mapper119_Init}, - {(uint8_t*)"FDS TOBIDASE", 120, Mapper120_Init}, - {(uint8_t*)"MMC3 PIRATE PROT. A", 121, Mapper121_Init}, -/* {(uint8_t*)"", 122, Mapper122_Init}, */ - {(uint8_t*)"MMC3 PIRATE H2288", 123, UNLH2288_Init}, -/* {(uint8_t*)"", 124, Mapper124_Init}, */ - {(uint8_t*)"FDS LH32", 125, LH32_Init}, - {(uint8_t*)"PowerJoy 84-in-1 PJ-008", 126, Mapper126_Init}, -/* {(uint8_t*)"", 127, Mapper127_Init}, */ -/* {(uint8_t*)"", 128, Mapper128_Init}, */ -/* {(uint8_t*)"", 129, Mapper129_Init}, */ -/* {(uint8_t*)"", 130, Mapper130_Init}, */ -/* {(uint8_t*)"", 131, Mapper131_Init}, */ - {(uint8_t*)"TXC/UNL-22211", 132, Mapper132_Init}, - {(uint8_t*)"SA72008", 133, SA72008_Init}, -/* {(uint8_t*)"MMC3 BMC PIRATE", 134, Mapper134_Init}, */ - {(uint8_t*)"MMC3 BMC PIRATE", 134, Bs5652_Init}, -/* {(uint8_t*)"", 135, Mapper135_Init}, */ - {(uint8_t*)"Sachen 3011", 136, Mapper136_Init}, - {(uint8_t*)"S8259D", 137, S8259D_Init}, - {(uint8_t*)"S8259B", 138, S8259B_Init}, - {(uint8_t*)"S8259C", 139, S8259C_Init}, - {(uint8_t*)"JALECO JF-11/14", 140, Mapper140_Init}, - {(uint8_t*)"S8259A", 141, S8259A_Init}, - {(uint8_t*)"UNLKS7032", 142, UNLKS7032_Init}, - {(uint8_t*)"TCA01", 143, TCA01_Init}, - {(uint8_t*)"AGCI 50282", 144, Mapper144_Init}, - {(uint8_t*)"SA72007", 145, SA72007_Init}, - {(uint8_t*)"SA0161M", 146, SA0161M_Init}, - {(uint8_t*)"Sachen 3018 board", 147, Mapper147_Init}, - {(uint8_t*)"SA0037", 148, SA0037_Init}, - {(uint8_t*)"SA0036", 149, SA0036_Init}, - {(uint8_t*)"SA-015/SA-630", 150, S74LS374N_Init}, - {(uint8_t*)"", 151, Mapper151_Init}, - {(uint8_t*)"", 152, Mapper152_Init}, - {(uint8_t*)"BANDAI SRAM", 153, Mapper153_Init}, /* Bandai board 16 with SRAM instead of EEPROM */ - {(uint8_t*)"", 154, Mapper154_Init}, - {(uint8_t*)"", 155, Mapper155_Init}, - {(uint8_t*)"", 156, Mapper156_Init}, - {(uint8_t*)"BANDAI BARCODE", 157, Mapper157_Init}, - {(uint8_t*)"TENGEN 800037", 158, Mapper158_Init}, - {(uint8_t*)"BANDAI 24C01", 159, Mapper159_Init}, /* Different type of EEPROM on the bandai board */ - {(uint8_t*)"SA009", 160, SA009_Init}, -/* {(uint8_t*)"", 161, Mapper161_Init}, */ - {(uint8_t*)"", 162, UNLFS304_Init}, - {(uint8_t*)"", 163, Mapper163_Init}, - {(uint8_t*)"", 164, Mapper164_Init}, - {(uint8_t*)"", 165, Mapper165_Init}, - {(uint8_t*)"SUBOR Rev. A", 166, Mapper166_Init}, - {(uint8_t*)"SUBOR Rev. B", 167, Mapper167_Init}, - {(uint8_t*)"", 168, Mapper168_Init}, -/* {(uint8_t*)"", 169, Mapper169_Init}, */ - {(uint8_t*)"", 170, Mapper170_Init}, - {(uint8_t*)"", 171, Mapper171_Init}, - {(uint8_t*)"Super Mega P-4070", 172, Mapper172_Init}, - {(uint8_t*)"Idea-Tek ET.xx", 173, Mapper173_Init}, -/* {(uint8_t*)"", 174, Mapper174_Init}, */ - {(uint8_t*)"", 175, Mapper175_Init}, - {(uint8_t*)"BMCFK23C", 176, BMCFK23C_Init}, /* zero 26-may-2012 - well, i have some WXN junk games that use 176 for instance ????. i dont know what game uses this BMCFK23C as mapper 176. we'll have to make a note when we find it. */ - {(uint8_t*)"", 177, Mapper177_Init}, - {(uint8_t*)"", 178, Mapper178_Init}, -/* {(uint8_t*)"", 179, Mapper179_Init}, */ - {(uint8_t*)"", 180, Mapper180_Init}, - {(uint8_t*)"", 181, Mapper181_Init}, -/* {(uint8_t*)"", 182, Mapper182_Init}, */ /* Deprecated, dupe of Mapper 114 */ - {(uint8_t*)"", 183, Mapper183_Init}, - {(uint8_t*)"", 184, Mapper184_Init}, - {(uint8_t*)"", 185, Mapper185_Init}, - {(uint8_t*)"", 186, Mapper186_Init}, - {(uint8_t*)"", 187, Mapper187_Init}, - {(uint8_t*)"", 188, Mapper188_Init}, - {(uint8_t*)"", 189, Mapper189_Init}, - {(uint8_t*)"", 190, Mapper190_Init}, - {(uint8_t*)"", 191, Mapper191_Init}, - {(uint8_t*)"TW MMC3+VRAM Rev. B", 192, Mapper192_Init}, - {(uint8_t*)"NTDEC TC-112", 193, Mapper193_Init}, /* War in the Gulf */ - {(uint8_t*)"TW MMC3+VRAM Rev. C", 194, Mapper194_Init}, - {(uint8_t*)"TW MMC3+VRAM Rev. D", 195, Mapper195_Init}, - {(uint8_t*)"", 196, Mapper196_Init}, - {(uint8_t*)"", 197, Mapper197_Init}, - {(uint8_t*)"TW MMC3+VRAM Rev. E", 198, Mapper198_Init}, - {(uint8_t*)"", 199, Mapper199_Init}, - {(uint8_t*)"", 200, Mapper200_Init}, - {(uint8_t*)"21-in-1", 201, Mapper201_Init}, - {(uint8_t*)"", 202, Mapper202_Init}, - {(uint8_t*)"", 203, Mapper203_Init}, - {(uint8_t*)"", 204, Mapper204_Init}, - {(uint8_t*)"BMC 15-in-1/3-in-1", 205, Mapper205_Init}, - {(uint8_t*)"NAMCOT 108 Rev. C", 206, Mapper206_Init}, /* Deprecated, Used to be "DEIROM" whatever it means, but actually simple version of MMC3 */ - {(uint8_t*)"TAITO X1-005 Rev. B", 207, Mapper207_Init}, - {(uint8_t*)"", 208, Mapper208_Init}, - {(uint8_t*)"HUMMER/JY BOARD", 209, Mapper209_Init}, - {(uint8_t*)"", 210, Mapper210_Init}, - {(uint8_t*)"HUMMER/JY BOARD", 211, Mapper211_Init}, - {(uint8_t*)"", 212, Mapper212_Init}, - {(uint8_t*)"", 213, Mapper213_Init}, - {(uint8_t*)"", 214, Mapper214_Init}, - {(uint8_t*)"UNL-8237", 215, UNL8237_Init}, - {(uint8_t*)"", 216, Mapper216_Init}, - {(uint8_t*)"", 217, Mapper217_Init}, /* Redefined to a new Discrete BMC mapper */ - {(uint8_t*)"Magic Floor", 218, Mapper218_Init}, - {(uint8_t*)"UNLA9746", 219, UNLA9746_Init}, - {(uint8_t*)"Debug Mapper", 220, UNLKS7057_Init}, - {(uint8_t*)"UNLN625092", 221, UNLN625092_Init}, - {(uint8_t*)"", 222, Mapper222_Init}, -/* {(uint8_t*)"", 223, Mapper223_Init}, */ - {(uint8_t*)"KT-008", 224, Mapper224_Init}, - {(uint8_t*)"", 225, Mapper225_Init}, - {(uint8_t*)"BMC 22+20-in-1", 226, Mapper226_Init}, - {(uint8_t*)"", 227, Mapper227_Init}, - {(uint8_t*)"", 228, Mapper228_Init}, - {(uint8_t*)"", 229, Mapper229_Init}, - {(uint8_t*)"BMC Contra+22-in-1", 230, Mapper230_Init}, - {(uint8_t*)"", 231, Mapper231_Init}, - {(uint8_t*)"BMC QUATTRO", 232, Mapper232_Init}, - {(uint8_t*)"BMC 22+20-in-1 RST", 233, Mapper233_Init}, - {(uint8_t*)"BMC MAXI", 234, Mapper234_Init}, - {(uint8_t*)"Golden Game", 235, Mapper235_Init}, -/* {(uint8_t*)"", 236, Mapper236_Init}, */ - {(uint8_t*)"Teletubbies / Y2K", 237, Mapper237_Init}, - {(uint8_t*)"UNL6035052", 238, UNL6035052_Init}, -/* {(uint8_t*)"", 239, Mapper239_Init}, */ - {(uint8_t*)"", 240, Mapper240_Init}, - {(uint8_t*)"", 241, Mapper241_Init}, - {(uint8_t*)"", 242, Mapper242_Init}, - {(uint8_t*)"SA-020A", 243, S74LS374N_Init}, - {(uint8_t*)"DECATHLON", 244, Mapper244_Init}, - {(uint8_t*)"", 245, Mapper245_Init}, - {(uint8_t*)"FONG SHEN BANG", 246, Mapper246_Init}, -/* {(uint8_t*)"", 247, Mapper247_Init}, */ -/* {(uint8_t*)"", 248, Mapper248_Init}, */ - {(uint8_t*)"", 249, Mapper249_Init}, - {(uint8_t*)"", 250, Mapper250_Init}, -/* {(uint8_t*)"", 251, Mapper251_Init}, */ /* No good dumps for this mapper, use UNIF version */ - {(uint8_t*)"SAN GUO ZHI PIRATE", 252, Mapper252_Init}, - {(uint8_t*)"DRAGON BALL PIRATE", 253, Mapper253_Init}, - {(uint8_t*)"", 254, Mapper254_Init}, - {(uint8_t*)"", 255, Mapper255_Init}, /* Duplicate of M225? */ +#define INES_BOARD_BEGIN() static BMAPPINGLocal bmap[] = { +#define INES_BOARD_END() { (uint8_t*)"", 0, NULL} }; +#define INES_BOARD(a, b, c) { a, b, c }, - /* -------------- ----NES 2.0 -------------------------- */ +INES_BOARD_BEGIN() + INES_BOARD( "NROM", 0, NROM_Init ) + INES_BOARD( "MMC1", 1, Mapper1_Init ) + INES_BOARD( "UNROM", 2, UNROM_Init ) + INES_BOARD( "CNROM", 3, CNROM_Init ) + INES_BOARD( "MMC3", 4, Mapper4_Init ) + INES_BOARD( "MMC5", 5, Mapper5_Init ) + INES_BOARD( "FFE Rev. A", 6, Mapper6_Init ) + INES_BOARD( "ANROM", 7, ANROM_Init ) + INES_BOARD( "", 8, Mapper8_Init ) /* Nogaems, it's worthless */ + INES_BOARD( "MMC2", 9, Mapper9_Init ) + INES_BOARD( "MMC4", 10, Mapper10_Init ) + INES_BOARD( "Color Dreams", 11, Mapper11_Init ) + INES_BOARD( "REX DBZ 5", 12, Mapper12_Init ) + INES_BOARD( "CPROM", 13, CPROM_Init ) + INES_BOARD( "REX SL-1632", 14, UNLSL1632_Init ) + INES_BOARD( "100-in-1", 15, Mapper15_Init ) + INES_BOARD( "BANDAI 24C02", 16, Mapper16_Init ) + INES_BOARD( "FFE Rev. B", 17, Mapper17_Init ) + INES_BOARD( "JALECO SS880006", 18, Mapper18_Init ) /* JF-NNX (EB89018-30007) boards */ + INES_BOARD( "Namcot 106", 19, Mapper19_Init ) +/* INES_BOARD( "", 20, Mapper20_Init ) */ + INES_BOARD( "Konami VRC2/VRC4 A", 21, Mapper21_Init ) + INES_BOARD( "Konami VRC2/VRC4 B", 22, Mapper22_Init ) + INES_BOARD( "Konami VRC2/VRC4 C", 23, Mapper23_Init ) + INES_BOARD( "Konami VRC6 Rev. A", 24, Mapper24_Init ) + INES_BOARD( "Konami VRC2/VRC4 D", 25, Mapper25_Init ) + INES_BOARD( "Konami VRC6 Rev. B", 26, Mapper26_Init ) + INES_BOARD( "CC-21 MI HUN CHE", 27, UNLCC21_Init ) /* Former dupe for VRC2/VRC4 mapper, redefined with crc to mihunche boards */ + INES_BOARD( "Action 53", 28, Mapper28_Init ) + INES_BOARD( "", 29, Mapper29_Init ) + INES_BOARD( "UNROM 512", 30, UNROM512_Init ) + INES_BOARD( "infineteNesLives-NSF", 31, Mapper31_Init ) + INES_BOARD( "IREM G-101", 32, Mapper32_Init ) + INES_BOARD( "TC0190FMC/TC0350FMR", 33, Mapper33_Init ) + INES_BOARD( "IREM I-IM/BNROM", 34, Mapper34_Init ) + INES_BOARD( "Wario Land 2", 35, UNLSC127_Init ) + INES_BOARD( "TXC Policeman", 36, Mapper36_Init ) + INES_BOARD( "PAL-ZZ SMB/TETRIS/NWC", 37, Mapper37_Init ) + INES_BOARD( "Bit Corp.", 38, Mapper38_Init ) /* Crime Busters */ +/* INES_BOARD( "", 39, Mapper39_Init ) */ + INES_BOARD( "SMB2j FDS", 40, Mapper40_Init ) + INES_BOARD( "CALTRON 6-in-1", 41, Mapper41_Init ) + INES_BOARD( "BIO MIRACLE FDS", 42, Mapper42_Init ) + INES_BOARD( "FDS SMB2j LF36", 43, Mapper43_Init ) + INES_BOARD( "MMC3 BMC PIRATE A", 44, Mapper44_Init ) + INES_BOARD( "MMC3 BMC PIRATE B", 45, Mapper45_Init ) + INES_BOARD( "RUMBLESTATION 15-in-1", 46, Mapper46_Init ) + INES_BOARD( "NES-QJ SSVB/NWC", 47, Mapper47_Init ) + INES_BOARD( "TAITO TCxxx", 48, Mapper48_Init ) + INES_BOARD( "MMC3 BMC PIRATE C", 49, Mapper49_Init ) + INES_BOARD( "SMB2j FDS Rev. A", 50, Mapper50_Init ) + INES_BOARD( "11-in-1 BALL SERIES", 51, Mapper51_Init ) /* 1993 year version */ + INES_BOARD( "MMC3 BMC PIRATE D", 52, Mapper52_Init ) + INES_BOARD( "SUPERVISION 16-in-1", 53, Supervision16_Init ) +/* INES_BOARD( "", 54, Mapper54_Init ) */ +/* INES_BOARD( "", 55, Mapper55_Init ) */ + INES_BOARD( "UNLKS202", 56, UNLKS202_Init ) + INES_BOARD( "SIMBPLE BMC PIRATE A", 57, Mapper57_Init ) + INES_BOARD( "SIMBPLE BMC PIRATE B", 58, BMCGK192_Init ) + INES_BOARD( "", 59, Mapper59_Init ) /* Check this out */ + INES_BOARD( "SIMBPLE BMC PIRATE C", 60, BMCD1038_Init ) + INES_BOARD( "20-in-1 KAISER Rev. A", 61, Mapper61_Init ) + INES_BOARD( "700-in-1", 62, Mapper62_Init ) + INES_BOARD( "", 63, Mapper63_Init ) + INES_BOARD( "TENGEN RAMBO1", 64, Mapper64_Init ) + INES_BOARD( "IREM-H3001", 65, Mapper65_Init ) + INES_BOARD( "MHROM", 66, MHROM_Init ) + INES_BOARD( "SUNSOFT-FZII", 67, Mapper67_Init ) + INES_BOARD( "Sunsoft Mapper #4", 68, Mapper68_Init ) + INES_BOARD( "SUNSOFT-5/FME-7", 69, Mapper69_Init ) + INES_BOARD( "BA KAMEN DISCRETE", 70, Mapper70_Init ) + INES_BOARD( "CAMERICA BF9093", 71, Mapper71_Init ) + INES_BOARD( "JALECO JF-17", 72, Mapper72_Init ) + INES_BOARD( "KONAMI VRC3", 73, Mapper73_Init ) + INES_BOARD( "TW MMC3+VRAM Rev. A", 74, Mapper74_Init ) + INES_BOARD( "KONAMI VRC1", 75, Mapper75_Init ) + INES_BOARD( "NAMCOT 108 Rev. A", 76, Mapper76_Init ) + INES_BOARD( "IREM LROG017", 77, Mapper77_Init ) + INES_BOARD( "Irem 74HC161/32", 78, Mapper78_Init ) + INES_BOARD( "AVE/C&E/TXC BOARD", 79, Mapper79_Init ) + INES_BOARD( "TAITO X1-005 Rev. A", 80, Mapper80_Init ) +/* INES_BOARD( "", 81, Mapper81_Init ) */ + INES_BOARD( "TAITO X1-017", 82, Mapper82_Init ) + INES_BOARD( "YOKO VRC Rev. B", 83, Mapper83_Init ) +/* INES_BOARD( "", 84, Mapper84_Init ) */ + INES_BOARD( "KONAMI VRC7", 85, Mapper85_Init ) + INES_BOARD( "JALECO JF-13", 86, Mapper86_Init ) + INES_BOARD( "74*139/74 DISCRETE", 87, Mapper87_Init ) + INES_BOARD( "NAMCO 3433", 88, Mapper88_Init ) + INES_BOARD( "SUNSOFT-3", 89, Mapper89_Init ) /* SUNSOFT-2 mapper */ + INES_BOARD( "HUMMER/JY BOARD", 90, Mapper90_Init ) + INES_BOARD( "EARLY HUMMER/JY BOARD", 91, Mapper91_Init ) + INES_BOARD( "JALECO JF-19", 92, Mapper92_Init ) + INES_BOARD( "SUNSOFT-3R", 93, SUNSOFT_UNROM_Init ) /* SUNSOFT-2 mapper with VRAM, different wiring */ + INES_BOARD( "HVC-UN1ROM", 94, Mapper94_Init ) + INES_BOARD( "NAMCOT 108 Rev. B", 95, Mapper95_Init ) + INES_BOARD( "BANDAI OEKAKIDS", 96, Mapper96_Init ) + INES_BOARD( "IREM TAM-S1", 97, Mapper97_Init ) +/* INES_BOARD( "", 98, Mapper98_Init ) */ + INES_BOARD( "VS Uni/Dual- system", 99, Mapper99_Init ) +/* INES_BOARD( "", 100, Mapper100_Init ) */ + INES_BOARD( "", 101, Mapper101_Init ) +/* INES_BOARD( "", 102, Mapper102_Init ) */ + INES_BOARD( "FDS DOKIDOKI FULL", 103, Mapper103_Init ) + INES_BOARD( "CAMERICA GOLDENFIVE", 104, Mapper104_Init ) + INES_BOARD( "NES-EVENT NWC1990", 105, Mapper105_Init ) + INES_BOARD( "SMB3 PIRATE A", 106, Mapper106_Init ) + INES_BOARD( "MAGIC CORP A", 107, Mapper107_Init ) + INES_BOARD( "FDS UNROM BOARD", 108, Mapper108_Init ) +/* INES_BOARD( "", 109, Mapper109_Init ) */ +/* INES_BOARD( "", 110, Mapper110_Init ) */ + INES_BOARD( "Cheapocabra", 111, Mapper111_Init ) + INES_BOARD( "ASDER/NTDEC BOARD", 112, Mapper112_Init ) + INES_BOARD( "HACKER/SACHEN BOARD", 113, Mapper113_Init ) + INES_BOARD( "MMC3 SG PROT. A", 114, Mapper114_Init ) + INES_BOARD( "MMC3 PIRATE A", 115, Mapper115_Init ) + INES_BOARD( "MMC1/MMC3/VRC PIRATE", 116, UNLSL12_Init ) + INES_BOARD( "FUTURE MEDIA BOARD", 117, Mapper117_Init ) + INES_BOARD( "TSKROM", 118, TKSROM_Init ) + INES_BOARD( "NES-TQROM", 119, Mapper119_Init ) + INES_BOARD( "FDS TOBIDASE", 120, Mapper120_Init ) + INES_BOARD( "MMC3 PIRATE PROT. A", 121, Mapper121_Init ) +/* INES_BOARD( "", 122, Mapper122_Init ) */ + INES_BOARD( "MMC3 PIRATE H2288", 123, UNLH2288_Init ) +/* INES_BOARD( "", 124, Mapper124_Init ) */ + INES_BOARD( "FDS LH32", 125, LH32_Init ) + INES_BOARD( "PowerJoy 84-in-1 PJ-008", 126, Mapper126_Init ) +/* INES_BOARD( "", 127, Mapper127_Init ) */ +/* INES_BOARD( "", 128, Mapper128_Init ) */ +/* INES_BOARD( "", 129, Mapper129_Init ) */ +/* INES_BOARD( "", 130, Mapper130_Init ) */ +/* INES_BOARD( "", 131, Mapper131_Init ) */ + INES_BOARD( "TXC/UNL-22211", 132, Mapper132_Init ) + INES_BOARD( "SA72008", 133, SA72008_Init ) +/* INES_BOARD( "MMC3 BMC PIRATE", 134, Mapper134_Init ) */ + INES_BOARD( "MMC3 BMC PIRATE", 134, Bs5652_Init ) +/* INES_BOARD( "", 135, Mapper135_Init ) */ + INES_BOARD( "Sachen 3011", 136, Mapper136_Init ) + INES_BOARD( "S8259D", 137, S8259D_Init ) + INES_BOARD( "S8259B", 138, S8259B_Init ) + INES_BOARD( "S8259C", 139, S8259C_Init ) + INES_BOARD( "JALECO JF-11/14", 140, Mapper140_Init ) + INES_BOARD( "S8259A", 141, S8259A_Init ) + INES_BOARD( "UNLKS7032", 142, UNLKS7032_Init ) + INES_BOARD( "TCA01", 143, TCA01_Init ) + INES_BOARD( "AGCI 50282", 144, Mapper144_Init ) + INES_BOARD( "SA72007", 145, SA72007_Init ) + INES_BOARD( "SA0161M", 146, SA0161M_Init ) + INES_BOARD( "Sachen 3018 board", 147, Mapper147_Init ) + INES_BOARD( "SA0037", 148, SA0037_Init ) + INES_BOARD( "SA0036", 149, SA0036_Init ) + INES_BOARD( "SA-015/SA-630", 150, S74LS374N_Init ) + INES_BOARD( "", 151, Mapper151_Init ) + INES_BOARD( "", 152, Mapper152_Init ) + INES_BOARD( "BANDAI SRAM", 153, Mapper153_Init ) /* Bandai board 16 with SRAM instead of EEPROM */ + INES_BOARD( "", 154, Mapper154_Init ) + INES_BOARD( "", 155, Mapper155_Init ) + INES_BOARD( "", 156, Mapper156_Init ) + INES_BOARD( "BANDAI BARCODE", 157, Mapper157_Init ) + INES_BOARD( "TENGEN 800037", 158, Mapper158_Init ) + INES_BOARD( "BANDAI 24C01", 159, Mapper159_Init ) /* Different type of EEPROM on the bandai board */ + INES_BOARD( "SA009", 160, SA009_Init ) +/* INES_BOARD( "", 161, Mapper161_Init ) */ + INES_BOARD( "", 162, UNLFS304_Init ) + INES_BOARD( "", 163, Mapper163_Init ) + INES_BOARD( "", 164, Mapper164_Init ) + INES_BOARD( "", 165, Mapper165_Init ) + INES_BOARD( "SUBOR Rev. A", 166, Mapper166_Init ) + INES_BOARD( "SUBOR Rev. B", 167, Mapper167_Init ) + INES_BOARD( "", 168, Mapper168_Init ) +/* INES_BOARD( "", 169, Mapper169_Init ) */ + INES_BOARD( "", 170, Mapper170_Init ) + INES_BOARD( "", 171, Mapper171_Init ) + INES_BOARD( "Super Mega P-4070", 172, Mapper172_Init ) + INES_BOARD( "Idea-Tek ET.xx", 173, Mapper173_Init ) +/* INES_BOARD( "", 174, Mapper174_Init ) */ + INES_BOARD( "", 175, Mapper175_Init ) + INES_BOARD( "BMCFK23C", 176, BMCFK23C_Init ) /* zero 26-may-2012 - well, i have some WXN junk games that use 176 for instance ????. i dont know what game uses this BMCFK23C as mapper 176. we'll have to make a note when we find it. */ + INES_BOARD( "", 177, Mapper177_Init ) + INES_BOARD( "", 178, Mapper178_Init ) +/* INES_BOARD( "", 179, Mapper179_Init ) */ + INES_BOARD( "", 180, Mapper180_Init ) + INES_BOARD( "", 181, Mapper181_Init ) +/* INES_BOARD( "", 182, Mapper182_Init ) */ /* Deprecated, dupe of Mapper 114 */ + INES_BOARD( "", 183, Mapper183_Init ) + INES_BOARD( "", 184, Mapper184_Init ) + INES_BOARD( "", 185, Mapper185_Init ) + INES_BOARD( "", 186, Mapper186_Init ) + INES_BOARD( "", 187, Mapper187_Init ) + INES_BOARD( "", 188, Mapper188_Init ) + INES_BOARD( "", 189, Mapper189_Init ) + INES_BOARD( "", 190, Mapper190_Init ) + INES_BOARD( "", 191, Mapper191_Init ) + INES_BOARD( "TW MMC3+VRAM Rev. B", 192, Mapper192_Init ) + INES_BOARD( "NTDEC TC-112", 193, Mapper193_Init ) /* War in the Gulf */ + INES_BOARD( "TW MMC3+VRAM Rev. C", 194, Mapper194_Init ) + INES_BOARD( "TW MMC3+VRAM Rev. D", 195, Mapper195_Init ) + INES_BOARD( "", 196, Mapper196_Init ) + INES_BOARD( "", 197, Mapper197_Init ) + INES_BOARD( "TW MMC3+VRAM Rev. E", 198, Mapper198_Init ) + INES_BOARD( "", 199, Mapper199_Init ) + INES_BOARD( "", 200, Mapper200_Init ) + INES_BOARD( "21-in-1", 201, Mapper201_Init ) + INES_BOARD( "", 202, Mapper202_Init ) + INES_BOARD( "", 203, Mapper203_Init ) + INES_BOARD( "", 204, Mapper204_Init ) + INES_BOARD( "BMC 15-in-1/3-in-1", 205, Mapper205_Init ) + INES_BOARD( "NAMCOT 108 Rev. C", 206, Mapper206_Init ) /* Deprecated, Used to be "DEIROM" whatever it means, but actually simple version of MMC3 */ + INES_BOARD( "TAITO X1-005 Rev. B", 207, Mapper207_Init ) + INES_BOARD( "", 208, Mapper208_Init ) + INES_BOARD( "HUMMER/JY BOARD", 209, Mapper209_Init ) + INES_BOARD( "", 210, Mapper210_Init ) + INES_BOARD( "HUMMER/JY BOARD", 211, Mapper211_Init ) + INES_BOARD( "", 212, Mapper212_Init ) + INES_BOARD( "", 213, Mapper213_Init ) + INES_BOARD( "", 214, Mapper214_Init ) + INES_BOARD( "UNL-8237", 215, UNL8237_Init ) + INES_BOARD( "", 216, Mapper216_Init ) + INES_BOARD( "", 217, Mapper217_Init ) /* Redefined to a new Discrete BMC mapper */ + INES_BOARD( "Magic Floor", 218, Mapper218_Init ) + INES_BOARD( "UNLA9746", 219, UNLA9746_Init ) + INES_BOARD( "Debug Mapper", 220, UNLKS7057_Init ) + INES_BOARD( "UNLN625092", 221, UNLN625092_Init ) + INES_BOARD( "", 222, Mapper222_Init ) +/* INES_BOARD( "", 223, Mapper223_Init ) */ + INES_BOARD( "KT-008", 224, Mapper224_Init ) + INES_BOARD( "", 225, Mapper225_Init ) + INES_BOARD( "BMC 22+20-in-1", 226, Mapper226_Init ) + INES_BOARD( "", 227, Mapper227_Init ) + INES_BOARD( "", 228, Mapper228_Init ) + INES_BOARD( "", 229, Mapper229_Init ) + INES_BOARD( "BMC Contra+22-in-1", 230, Mapper230_Init ) + INES_BOARD( "", 231, Mapper231_Init ) + INES_BOARD( "BMC QUATTRO", 232, Mapper232_Init ) + INES_BOARD( "BMC 22+20-in-1 RST", 233, Mapper233_Init ) + INES_BOARD( "BMC MAXI", 234, Mapper234_Init ) + INES_BOARD( "Golden Game", 235, Mapper235_Init ) +/* INES_BOARD( "", 236, Mapper236_Init ) */ + INES_BOARD( "Teletubbies / Y2K", 237, Mapper237_Init ) + INES_BOARD( "UNL6035052", 238, UNL6035052_Init ) +/* INES_BOARD( "", 239, Mapper239_Init ) */ + INES_BOARD( "", 240, Mapper240_Init ) + INES_BOARD( "", 241, Mapper241_Init ) + INES_BOARD( "", 242, Mapper242_Init ) + INES_BOARD( "SA-020A", 243, S74LS374N_Init ) + INES_BOARD( "DECATHLON", 244, Mapper244_Init ) + INES_BOARD( "", 245, Mapper245_Init ) + INES_BOARD( "FONG SHEN BANG", 246, Mapper246_Init ) +/* INES_BOARD( "", 247, Mapper247_Init ) */ +/* INES_BOARD( "", 248, Mapper248_Init ) */ + INES_BOARD( "", 249, Mapper249_Init ) + INES_BOARD( "", 250, Mapper250_Init ) +/* INES_BOARD( "", 251, Mapper251_Init ) */ /* No good dumps for this mapper, use UNIF version */ + INES_BOARD( "SAN GUO ZHI PIRATE", 252, Mapper252_Init ) + INES_BOARD( "DRAGON BALL PIRATE", 253, Mapper253_Init ) + INES_BOARD( "", 254, Mapper254_Init ) + INES_BOARD( "", 255, Mapper255_Init ) /* Duplicate of M225? */ /* NES 2.0 BOARDS THAT DO NOT HAVE UNIF ASSOCIATION */ - {(uint8_t*)"OK-411", 361, GN45_Init}, /* OK-411 is emulated together with GN-45 */ - {(uint8_t*)"HUMMER/JY-052", 281, Mapper281_Init}, - {(uint8_t*)"GN-45", 366, GN45_Init}, - - {(uint8_t*)"GKCX1", 288, Mapper288_Init }, - {(uint8_t*)"Bit Corp 4-in-1", 357, Mapper357_Init }, - {(uint8_t*)"MMC3 PIRATE SFC-12", 372, Mapper372_Init }, - {(uint8_t*)"95/96 Super HiK 4-in-1", 374, Mapper374_Init }, - {(uint8_t*)"KN-42", 381, Mapper381_Init }, - {(uint8_t*)"Realtec 8031", 390, Mapper390_Init }, - {(uint8_t*)"60-1064-16L (FDS)", 538, Mapper538_Init }, - {(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}, - {(uint8_t*)"Bitcorp 31-in-1", 360, Mapper360_Init}, - {(uint8_t*)"Sachen 3014", 533, Mapper533_Init}, - {(uint8_t*)"830928C", 382, Mapper382_Init}, - {(uint8_t*)"NJ064", 534, Mapper534_Init}, - {(uint8_t*)"Kid Ikarus (FDS)", 539, Mapper539_Init}, - {(uint8_t*)"5-in-1 (CH-501)", 543, Mapper543_Init}, - {(uint8_t*)"", 550, Mapper550_Init}, - {(uint8_t*)"Brilliant Com Cocoma Pack", 516, Mapper516_Init}, - {(uint8_t*)"SB-5013/GCL8050/841242C", 359, Mapper359_Init}, - {(uint8_t*)"82112C", 540, Mapper540_Init}, - {(uint8_t*)"7-in-1 Rockman (JY-208)", 356, Mapper356_Init}, - {(uint8_t*)"Games Xplosion 121-in-1", 269, Mapper269_Init}, - {(uint8_t*)"Super Mario Family", 353, Mapper353_Init}, + INES_BOARD( "8-in-1 JY-119", 267, Mapper267_Init ) + INES_BOARD( "Games Xplosion 121-in-1", 269, Mapper269_Init ) + INES_BOARD( "HUMMER/JY-052", 281, Mapper281_Init ) + INES_BOARD( "GKCX1", 288, Mapper288_Init ) + INES_BOARD( "MMC3 BMC PIRATE", 294, Bs5652_Init ) /* nesdev redirects this as mapper 134 */ + INES_BOARD( "TXC 01-22110-000", 297, Mapper297_Init ) + INES_BOARD( "Super Mario Family", 353, Mapper353_Init ) + INES_BOARD( "7-in-1 Rockman (JY-208)", 356, Mapper356_Init ) + INES_BOARD( "Bit Corp 4-in-1", 357, Mapper357_Init ) + INES_BOARD( "SB-5013/GCL8050/841242C", 359, Mapper359_Init ) + INES_BOARD( "Bitcorp 31-in-1", 360, Mapper360_Init ) + INES_BOARD( "OK-411", 361, GN45_Init ) /* OK-411 is emulated together with GN-45 */ + INES_BOARD( "GN-45", 366, GN45_Init ) + INES_BOARD( "MMC3 PIRATE SFC-12", 372, Mapper372_Init ) + INES_BOARD( "95/96 Super HiK 4-in-1", 374, Mapper374_Init ) + INES_BOARD( "KN-42", 381, Mapper381_Init ) + INES_BOARD( "830928C", 382, Mapper382_Init ) + INES_BOARD( "Realtec 8031", 390, Mapper390_Init ) + INES_BOARD( "Brilliant Com Cocoma Pack", 516, Mapper516_Init ) + INES_BOARD( "Sachen 3014", 533, Mapper533_Init ) + INES_BOARD( "NJ064", 534, Mapper534_Init ) + INES_BOARD( "60-1064-16L (FDS)", 538, Mapper538_Init ) + INES_BOARD( "Kid Ikarus (FDS)", 539, Mapper539_Init ) + INES_BOARD( "82112C", 540, Mapper540_Init ) + INES_BOARD( "LittleCom 160-in-1", 541, Mapper541_Init ) + INES_BOARD( "5-in-1 (CH-501)", 543, Mapper543_Init ) + INES_BOARD( "", 550, Mapper550_Init ) /* UNIF to NES 2.0 BOARDS */ - {(uint8_t*)"OneBus", 256, UNLOneBus_Init }, - {(uint8_t*)"158B", 258, UNL158B_Init }, - {(uint8_t*)"F-15", 259, BMCF15_Init }, - {(uint8_t*)"HPxx / HP2018-A", 260, BMCHPxx_Init }, - {(uint8_t*)"810544-C-A1", 261, BMC810544CA1_Init }, - {(uint8_t*)"SHERO", 262, UNLSHeroes_Init }, - {(uint8_t*)"KOF97", 263, UNLKOF97_Init }, - {(uint8_t*)"YOKO", 264, UNLYOKO_Init }, - {(uint8_t*)"T-262", 265, BMCT262_Init }, - {(uint8_t*)"CITYFIGHT", 266, UNLCITYFIGHT_Init }, - {(uint8_t*)"COOLBOY", 268, COOLBOY_Init }, -/* {(uint8_t*)"MINDKIDS", 268, MINDKIDS_Init }, */ - {(uint8_t*)"80013-B", 274, BMC80013B_Init }, - {(uint8_t*)"GS-2004", 283, BMCGS2004_Init }, -/* {(uint8_t*)"GS-2013", 283, BMCGS2013_Init }, */ - {(uint8_t*)"A65AS", 285, BMCA65AS_Init }, - {(uint8_t*)"BS-5", 286, BMCBS5_Init }, - {(uint8_t*)"411120-C", 287, BMC411120C_Init }, -/* {(uint8_t*)"K-3088", 287, BMCK3088_Init }, */ - {(uint8_t*)"60311C", 289, BMC60311C_Init }, - {(uint8_t*)"NTD-03", 290, BMCNTD03_Init }, - {(uint8_t*)"DRAGONFIGHTER", 292, UNLBMW8544_Init }, - {(uint8_t*)"13in1JY110", 295, BMC13in1JY110_Init }, - {(uint8_t*)"TF1201", 298, UNLTF1201_Init }, - {(uint8_t*)"11160", 299, BMC11160_Init }, - {(uint8_t*)"190in1", 300, BMC190in1_Init }, - {(uint8_t*)"8157", 301, UNL8157_Init }, - {(uint8_t*)"KS7057", 302, UNLKS7057_Init }, - {(uint8_t*)"KS7017", 303, UNLKS7017_Init }, - {(uint8_t*)"SMB2J", 304, UNLSMB2J_Init }, - {(uint8_t*)"KS7031", 305, UNLKS7031_Init }, - {(uint8_t*)"KS7016", 306, UNLKS7016_Init }, - {(uint8_t*)"KS7037", 307, UNLKS7037_Init }, - {(uint8_t*)"TH2131-1", 308, UNLTH21311_Init }, - {(uint8_t*)"LH51", 309, LH51_Init }, - {(uint8_t*)"KS7013B", 312, UNLKS7013B_Init }, - {(uint8_t*)"RESET-TXROM", 313, BMCRESETTXROM_Init }, - {(uint8_t*)"64in1NoRepeat", 314, BMC64in1nr_Init }, - {(uint8_t*)"830134C", 315, BMC830134C_Init }, - {(uint8_t*)"HP898F", 319, BMCHP898F_Init }, - {(uint8_t*)"830425C-4391T", 320, BMC830425C4391T_Init }, - {(uint8_t*)"K-3033", 322, BMCK3033_Init }, - {(uint8_t*)"FARID_SLROM_8-IN-1", 323, FARIDSLROM8IN1_Init }, - {(uint8_t*)"FARID_UNROM_8-IN-1", 324, FARIDUNROM_Init }, - {(uint8_t*)"MALISB", 325, UNLMaliSB_Init }, - {(uint8_t*)"10-24-C-A1", 327, BMC1024CA1_Init }, - {(uint8_t*)"RT-01", 328, UNLRT01_Init }, - {(uint8_t*)"EDU2000", 329, UNLEDU2000_Init }, - {(uint8_t*)"12-IN-1", 331, BMC12IN1_Init }, - {(uint8_t*)"WS", 332, BMCWS_Init }, - {(uint8_t*)"NEWSTAR-GRM070-8IN1", 333, BMC8IN1_Init }, - {(uint8_t*)"CTC-09", 335, BMCCTC09_Init }, - {(uint8_t*)"K-3046", 336, BMCK3046_Init }, - {(uint8_t*)"CTC-12IN1", 337, BMCCTC12IN1_Init }, - {(uint8_t*)"SA005-A", 338, BMCSA005A_Init }, - {(uint8_t*)"K-3006", 339, BMCK3006_Init }, - {(uint8_t*)"K-3036", 340, BMCK3036_Init }, - {(uint8_t*)"TJ-03", 341, BMCTJ03_Init }, - {(uint8_t*)"GN-26", 344, BMCGN26_Init }, - {(uint8_t*)"L6IN1", 345, BMCL6IN1_Init }, - {(uint8_t*)"KS7012", 346, UNLKS7012_Init }, - {(uint8_t*)"KS7030", 347, UNLKS7030_Init }, - {(uint8_t*)"830118C", 348, BMC830118C_Init }, - {(uint8_t*)"G-146", 349, BMCG146_Init }, - {(uint8_t*)"891227", 350, BMC891227_Init }, - {(uint8_t*)"3D-BLOCK", 355, UNL3DBlock_Init }, - {(uint8_t*)"Super Mario Bros. Party (N49C-300)", 369, Mapper369_Init }, - {(uint8_t*)"NC7000M", 391, NC7000M_Init }, - {(uint8_t*)"831019C J-2282", 402, J2282_Init }, - {(uint8_t*)"SA-9602B", 513, SA9602B_Init }, - {(uint8_t*)"DANCE2000", 518, UNLD2000_Init }, - {(uint8_t*)"EH8813A", 519, UNLEH8813A_Init }, - {(uint8_t*)"DREAMTECH01", 521, DreamTech01_Init }, - {(uint8_t*)"LH10", 522, LH10_Init }, - {(uint8_t*)"900218", 524, BTL900218_Init }, - {(uint8_t*)"KS7021A", 525, UNLKS7021A_Init }, - {(uint8_t*)"BJ-56", 526, UNLBJ56_Init }, - {(uint8_t*)"AX-40G", 527, UNLAX40G_Init }, - {(uint8_t*)"T-230", 529, UNLT230_Init }, - {(uint8_t*)"AX5705", 530, UNLAX5705_Init }, - {(uint8_t*)"LH53", 535, LH53_Init }, + INES_BOARD( "OneBus", 256, UNLOneBus_Init ) + INES_BOARD( "158B", 258, UNL158B_Init ) + INES_BOARD( "F-15", 259, BMCF15_Init ) + INES_BOARD( "HPxx / HP2018-A", 260, BMCHPxx_Init ) + INES_BOARD( "810544-C-A1", 261, BMC810544CA1_Init ) + INES_BOARD( "SHERO", 262, UNLSHeroes_Init ) + INES_BOARD( "KOF97", 263, UNLKOF97_Init ) + INES_BOARD( "YOKO", 264, UNLYOKO_Init ) + INES_BOARD( "T-262", 265, BMCT262_Init ) + INES_BOARD( "CITYFIGHT", 266, UNLCITYFIGHT_Init ) + INES_BOARD( "COOLBOY", 268, COOLBOY_Init ) +/* INES_BOARD( "MINDKIDS", 268, MINDKIDS_Init ) */ + INES_BOARD( "80013-B", 274, BMC80013B_Init ) + INES_BOARD( "GS-2004", 283, BMCGS2004_Init ) +/* INES_BOARD( "GS-2013", 283, BMCGS2013_Init ) */ + INES_BOARD( "A65AS", 285, BMCA65AS_Init ) + INES_BOARD( "BS-5", 286, BMCBS5_Init ) + INES_BOARD( "411120-C", 287, BMC411120C_Init ) +/* INES_BOARD( "K-3088", 287, BMCK3088_Init ) */ + INES_BOARD( "60311C", 289, BMC60311C_Init ) + INES_BOARD( "NTD-03", 290, BMCNTD03_Init ) + INES_BOARD( "DRAGONFIGHTER", 292, UNLBMW8544_Init ) + INES_BOARD( "13in1JY110", 295, BMC13in1JY110_Init ) + INES_BOARD( "TF1201", 298, UNLTF1201_Init ) + INES_BOARD( "11160", 299, BMC11160_Init ) + INES_BOARD( "190in1", 300, BMC190in1_Init ) + INES_BOARD( "8157", 301, UNL8157_Init ) + INES_BOARD( "KS7057", 302, UNLKS7057_Init ) + INES_BOARD( "KS7017", 303, UNLKS7017_Init ) + INES_BOARD( "SMB2J", 304, UNLSMB2J_Init ) + INES_BOARD( "KS7031", 305, UNLKS7031_Init ) + INES_BOARD( "KS7016", 306, UNLKS7016_Init ) + INES_BOARD( "KS7037", 307, UNLKS7037_Init ) + INES_BOARD( "TH2131-1", 308, UNLTH21311_Init ) + INES_BOARD( "LH51", 309, LH51_Init ) + INES_BOARD( "KS7013B", 312, UNLKS7013B_Init ) + INES_BOARD( "RESET-TXROM", 313, BMCRESETTXROM_Init ) + INES_BOARD( "64in1NoRepeat", 314, BMC64in1nr_Init ) + INES_BOARD( "830134C", 315, BMC830134C_Init ) + INES_BOARD( "HP898F", 319, BMCHP898F_Init ) + INES_BOARD( "830425C-4391T", 320, BMC830425C4391T_Init ) + INES_BOARD( "K-3033", 322, BMCK3033_Init ) + INES_BOARD( "FARID_SLROM_8-IN-1", 323, FARIDSLROM8IN1_Init ) + INES_BOARD( "FARID_UNROM_8-IN-1", 324, FARIDUNROM_Init ) + INES_BOARD( "MALISB", 325, UNLMaliSB_Init ) + INES_BOARD( "10-24-C-A1", 327, BMC1024CA1_Init ) + INES_BOARD( "RT-01", 328, UNLRT01_Init ) + INES_BOARD( "EDU2000", 329, UNLEDU2000_Init ) + INES_BOARD( "12-IN-1", 331, BMC12IN1_Init ) + INES_BOARD( "WS", 332, BMCWS_Init ) + INES_BOARD( "NEWSTAR-GRM070-8IN1", 333, BMC8IN1_Init ) + INES_BOARD( "CTC-09", 335, BMCCTC09_Init ) + INES_BOARD( "K-3046", 336, BMCK3046_Init ) + INES_BOARD( "CTC-12IN1", 337, BMCCTC12IN1_Init ) + INES_BOARD( "SA005-A", 338, BMCSA005A_Init ) + INES_BOARD( "K-3006", 339, BMCK3006_Init ) + INES_BOARD( "K-3036", 340, BMCK3036_Init ) + INES_BOARD( "TJ-03", 341, BMCTJ03_Init ) + INES_BOARD( "GN-26", 344, BMCGN26_Init ) + INES_BOARD( "L6IN1", 345, BMCL6IN1_Init ) + INES_BOARD( "KS7012", 346, UNLKS7012_Init ) + INES_BOARD( "KS7030", 347, UNLKS7030_Init ) + INES_BOARD( "830118C", 348, BMC830118C_Init ) + INES_BOARD( "G-146", 349, BMCG146_Init ) + INES_BOARD( "891227", 350, BMC891227_Init ) + INES_BOARD( "3D-BLOCK", 355, UNL3DBlock_Init ) + INES_BOARD( "N49C-300", 369, Mapper369_Init ) + INES_BOARD( "NC7000M", 391, NC7000M_Init ) + INES_BOARD( "831019C J-2282", 402, J2282_Init ) + INES_BOARD( "SA-9602B", 513, SA9602B_Init ) + INES_BOARD( "DANCE2000", 518, UNLD2000_Init ) + INES_BOARD( "EH8813A", 519, UNLEH8813A_Init ) + INES_BOARD( "DREAMTECH01", 521, DreamTech01_Init ) + INES_BOARD( "LH10", 522, LH10_Init ) + INES_BOARD( "900218", 524, BTL900218_Init ) + INES_BOARD( "KS7021A", 525, UNLKS7021A_Init ) + INES_BOARD( "BJ-56", 526, UNLBJ56_Init ) + INES_BOARD( "AX-40G", 527, UNLAX40G_Init ) + INES_BOARD( "T-230", 529, UNLT230_Init ) + INES_BOARD( "AX5705", 530, UNLAX5705_Init ) + INES_BOARD( "LH53", 535, LH53_Init ) +INES_BOARD_END() - {(uint8_t*)"", 0, NULL} -}; +static uint32 get_ines_version(void) { + if ((head.ROM_type2 & 0x0C) == 0x08) + return 1; + return 0; +} + +static uint32 get_ines_mapper_id(void) { + /* If byte 7 AND $0C = $08, and the size taking into account byte 9 does not exceed the actual size of the ROM image, then NES 2.0. + * If byte 7 AND $0C = $00, and bytes 12-15 are all 0, then iNES. + * Otherwise, archaic iNES. - nesdev*/ + uint32 ret; + switch (head.ROM_type2 & 0x0C) { + case 0x08: /* header version is NES 2.0 */ + ret = (((uint32)head.ROM_type3 << 8) & 0xF00) | (head.ROM_type2 & 0xF0) | (head.ROM_type >> 4); + break; + case 0x00: /* header version is iNES */ + ret = (head.ROM_type2 & 0xF0) | (head.ROM_type >> 4); + break; + default: /* any other value is Archaic iNes, byte 7-15 not used */ + ret = (head.ROM_type >> 4); + break; + } + return ret; +} + +static void rom_load_ines(void) { + ROM_size = head.ROM_size; + VROM_size = head.VROM_size; + iNESCart.mirror = (head.ROM_type & 8) ? 2 : (head.ROM_type & 1); + iNESCart.battery = (head.ROM_type & 2) ? 1 : 0; + iNESCart.mapper = get_ines_mapper_id(); +} + +static void rom_load_ines2(void) { + ROM_size = head.ROM_size | ((head.upper_PRG_CHR_size >> 0) & 0xF) << 8; + VROM_size = head.VROM_size | ((head.upper_PRG_CHR_size >> 4) & 0xF) << 8; + iNESCart.mirror = (head.ROM_type & 8) ? 2 : (head.ROM_type & 1); + iNESCart.battery = (head.ROM_type & 2) ? 1 : 0; + iNESCart.mapper = get_ines_mapper_id(); + iNESCart.submapper = (head.ROM_type3 >> 4) & 0x0F; + iNESCart.region = head.Region & 3; + if (head.PRGRAM_size & 0x0F) iNESCart.PRGRamSize = 64 << ((head.PRGRAM_size >> 0) & 0x0F); + if (head.PRGRAM_size & 0xF0) iNESCart.PRGRamSaveSize = 64 << ((head.PRGRAM_size >> 4) & 0x0F); + if (head.CHRRAM_size & 0x0F) iNESCart.CHRRamSize = 64 << ((head.CHRRAM_size >> 0) & 0x0F); + if (head.CHRRAM_size & 0xF0) iNESCart.CHRRamSaveSize = 64 << ((head.CHRRAM_size >> 4) & 0x0F); +} int iNESLoad(const char *name, FCEUFILE *fp) { struct md5_context md5; - char* mappername = NULL; - uint64 filesize = FCEU_fgetsize(fp); - uint64 romSize = 0; - uint32 mappertest = 0; - uint32 prgRom = 0; - uint32 chrRom = 0; - uint32 region = 0; + char* mappername = NULL; + uint64 filesize = FCEU_fgetsize(fp); + uint64 romSize = 0; + uint32 mappertest = 0; + /* used for malloc and cart mapping */ + uint32 rom_size_pow2 = 0; + uint32 vrom_size_pow2 = 0; if (FCEU_fread(&head, 1, 16, fp) != 16) return 0; @@ -809,40 +852,15 @@ int iNESLoad(const char *name, FCEUFILE *fp) { memset((char*)(&head) + 0xA, 0, 0x6); } - /* If byte 7 AND $0C = $08, and the size taking into account byte 9 does not exceed the actual size of the ROM image, then NES 2.0. - * If byte 7 AND $0C = $00, and bytes 12-15 are all 0, then iNES. - * Otherwise, archaic iNES. - nesdev*/ - switch (head.ROM_type2 & 0x0C) { - case 0x08: /* header version is NES 2.0 */ - iNES2 = 1; - /* fallthrough */ - case 0x00: /* header version is iNES */ - MapperNo = (head.ROM_type >> 4) | (head.ROM_type2 & 0xF0); - break; - default: /* any other value is Archaic iNes, byte 7-15 not used */ - MapperNo = (head.ROM_type >> 4); - break; - } - Mirroring = (head.ROM_type & 8) ? 2 : (head.ROM_type & 1); - prgRom = head.ROM_size; - chrRom = head.VROM_size; - subMapper = 0; + iNESCart.iNES2 = get_ines_version(); - if (iNES2) { - MapperNo |= ((uint32)head.ROM_type3 << 8) & 0xF00; - prgRom |= ((uint32)head.upper_PRG_CHR_size << 8) & 0xF00; - chrRom |= ((uint32)head.upper_PRG_CHR_size << 4) & 0xF00; + if (!iNESCart.iNES2) + rom_load_ines(); + else + rom_load_ines2(); - subMapper = (head.ROM_type3 >> 4) & 0x0F; - iNESCart.PRGRamSize = (head.PRGRAM_size & 0x0F) ? (64 << (head.PRGRAM_size & 0x0F)) : 0; - iNESCart.CHRRamSize = (head.CHRRAM_size & 0x0F) ? (64 << (head.CHRRAM_size & 0x0F)) : 0; - iNESCart.PRGRamSaveSize = (head.PRGRAM_size & 0xF0) ? (64 << ((head.PRGRAM_size & 0xF0) >> 4)) : 0; - iNESCart.CHRRamSaveSize = (head.CHRRAM_size & 0xF0) ? (64 << ((head.CHRRAM_size & 0xF0) >> 4)) : 0; - region = (head.Region & 3); - } else { - if (!prgRom) - prgRom = 256; - } + if (!ROM_size) + ROM_size = 256; /* Trainer */ if (head.ROM_type & 4) { @@ -851,58 +869,53 @@ int iNESLoad(const char *name, FCEUFILE *fp) { filesize -= 512; } - romSize = (prgRom * 0x4000) + (chrRom * 0x2000); + romSize = (ROM_size * 0x4000) + (VROM_size * 0x2000); + if (romSize > filesize) { FCEU_PrintError(" File length is too short to contain all data reported from header by %llu\n", romSize - filesize); } else if (romSize < filesize) FCEU_PrintError(" File contains %llu bytes of unused data\n", filesize - romSize); - iNESCart.PRGRomSize = prgRom << 14; - iNESCart.CHRRomSize = chrRom << 13; + rom_size_pow2 = uppow2(ROM_size) * 0x4000; - ROM_size = uppow2(prgRom); - - if (chrRom) - VROM_size = uppow2(chrRom); - - if ((ROM = (uint8*)FCEU_malloc(ROM_size << 14)) == NULL) + if ((ROM = (uint8*)FCEU_malloc(rom_size_pow2)) == NULL) return 0; - memset(ROM, 0xFF, ROM_size << 14); + + memset(ROM, 0xFF, rom_size_pow2); + FCEU_fread(ROM, 0x4000, ROM_size, fp); if (VROM_size) { - if ((VROM = (uint8*)FCEU_malloc(VROM_size << 13)) == NULL) { + vrom_size_pow2 = uppow2(VROM_size) * 0x2000; + + if ((VROM = (uint8*)FCEU_malloc(vrom_size_pow2)) == NULL) { free(ROM); ROM = NULL; return 0; } - memset(VROM, 0xFF, VROM_size << 13); + + memset(VROM, 0xFF, vrom_size_pow2); + FCEU_fread(VROM, 0x2000, VROM_size, fp); } - ResetCartMapping(); - ResetExState(0, 0); + iNESCart.PRGRomSize = ROM_size * 0x4000; + iNESCart.CHRRomSize = VROM_size * 0x2000; - SetupCartPRGMapping(0, ROM, ROM_size << 14, 0); - - FCEU_fread(ROM, 0x4000, prgRom, fp); - - if (VROM_size) - FCEU_fread(VROM, 0x2000, chrRom, fp); - - iNESCart.PRGCRC32 = CalcCRC32(0, ROM, prgRom * 0x4000); - iNESCart.CHRCRC32 = CalcCRC32(0, VROM, chrRom * 0x2000); - iNESCart.CRC32 = CalcCRC32(iNESCart.PRGCRC32, VROM, chrRom * 0x2000); + iNESCart.PRGCRC32 = CalcCRC32(0, ROM, ROM_size * 0x4000); + iNESCart.CHRCRC32 = CalcCRC32(0, VROM, VROM_size * 0x2000); + iNESCart.CRC32 = CalcCRC32(iNESCart.PRGCRC32, VROM, VROM_size * 0x2000); md5_starts(&md5); - md5_update(&md5, ROM, prgRom << 14); + md5_update(&md5, ROM, ROM_size * 0x4000); if (VROM_size) - md5_update(&md5, VROM, chrRom << 13); + md5_update(&md5, VROM, VROM_size * 0x2000); md5_finish(&md5, iNESCart.MD5); + memcpy(&GameInfo->MD5, &iNESCart.MD5, sizeof(iNESCart.MD5)); mappername = "Not Listed"; for (mappertest = 0; mappertest < (sizeof bmap / sizeof bmap[0]) - 1; mappertest++) { - if (bmap[mappertest].number == MapperNo) { + if (bmap[mappertest].number == iNESCart.mapper) { mappername = (char*)bmap[mappertest].name; break; } @@ -911,17 +924,17 @@ int iNESLoad(const char *name, FCEUFILE *fp) { FCEU_printf(" PRG-ROM CRC32: 0x%08X\n", iNESCart.PRGCRC32); FCEU_printf(" PRG+CHR CRC32: 0x%08X\n", iNESCart.CRC32); FCEU_printf(" PRG+CHR MD5: 0x%s\n", md5_asciistr(iNESCart.MD5)); - FCEU_printf(" PRG-ROM: %3d x 16KiB\n", prgRom); - FCEU_printf(" CHR-ROM: %3d x 8KiB\n", chrRom); + FCEU_printf(" PRG-ROM: %3d x 16KiB\n", ROM_size); + FCEU_printf(" CHR-ROM: %3d x 8KiB\n", VROM_size); - if (iNES2) { + if (iNESCart.iNES2) { const char *tv_region[] = { "NTSC", "PAL", "Multi-region", "Dendy" }; unsigned PRGRAM = iNESCart.PRGRamSize + iNESCart.PRGRamSaveSize; unsigned CHRRAM = iNESCart.CHRRamSize + iNESCart.CHRRamSaveSize; FCEU_printf(" NES 2.0 extended iNES.\n"); - FCEU_printf(" Mapper #: %3d\n", MapperNo); - FCEU_printf(" Sub Mapper #: %3d\n", subMapper); + FCEU_printf(" Mapper #: %3d\n", iNESCart.mapper); + FCEU_printf(" Sub Mapper #: %3d\n", iNESCart.submapper); FCEU_printf(" Mapper name: %s\n", mappername); if (PRGRAM || CHRRAM) { FCEU_printf(" PRG RAM: %d KB\n", PRGRAM / 1024); @@ -931,59 +944,71 @@ int iNESLoad(const char *name, FCEUFILE *fp) { FCEU_printf(" CHR RAM backed by battery: %d KiB\n", iNESCart.CHRRamSaveSize / 1024); } } - FCEU_printf(" Mirroring: %s\n", Mirroring == 2 ? "None (Four-screen)" : Mirroring ? "Vertical" : "Horizontal"); - FCEU_printf(" System: %s\n", tv_region[region]); + FCEU_printf(" Mirroring: %s\n", iNESCart.mirror == 2 ? "None (Four-screen)" : iNESCart.mirror ? "Vertical" : "Horizontal"); + FCEU_printf(" System: %s\n", tv_region[iNESCart.region]); FCEU_printf(" Trained: %s\n", (head.ROM_type & 4) ? "Yes" : "No"); } else { - FCEU_printf(" Mapper #: %3d\n", MapperNo); + FCEU_printf(" Mapper #: %3d\n", iNESCart.mapper); FCEU_printf(" Mapper name: %s\n", mappername); - FCEU_printf(" Mirroring: %s\n", Mirroring == 2 ? "None (Four-screen)" : Mirroring ? "Vertical" : "Horizontal"); + FCEU_printf(" Mirroring: %s\n", iNESCart.mirror == 2 ? "None (Four-screen)" : iNESCart.mirror ? "Vertical" : "Horizontal"); FCEU_printf(" Battery-backed: %s\n", (head.ROM_type & 2) ? "Yes" : "No"); FCEU_printf(" Trained: %s\n", (head.ROM_type & 4) ? "Yes" : "No"); } + ResetCartMapping(); + ResetExState(0, 0); + + SetupCartPRGMapping(0, ROM, rom_size_pow2, 0); + SetInput(); CheckHInfo(); { int x; uint64 partialmd5 = 0; + int mapper = iNESCart.mapper; + int mirroring = iNESCart.mirror; for (x = 0; x < 8; x++) { partialmd5 |= (uint64)iNESCart.MD5[7 - x] << (x * 8); } - FCEU_VSUniCheck(partialmd5, &MapperNo, &Mirroring); + FCEU_VSUniCheck(partialmd5, &mapper, &mirroring); + + if ((mapper != iNESCart.mapper) || (mirroring != iNESCart.mirror)) { + FCEU_PrintError("\n"); + FCEU_PrintError(" Incorrect VS-Unisystem header information!\n"); + if (mapper != iNESCart.mapper) FCEU_PrintError(" Mapper: %d\n", mapper); + if (mirroring != iNESCart.mirror) FCEU_PrintError(" Mirroring: %s\n", + (mirroring == 2) ? "None (Four-screen)" : mirroring ? "Vertical" : "Horizontal"); + iNESCart.mapper = mapper; + iNESCart.mirror = mirroring; + } } + /* Must remain here because above functions might change value of * VROM_size and free(VROM). */ if (VROM_size) - SetupCartCHRMapping(0, VROM, VROM_size * 0x2000, 0); + SetupCartCHRMapping(0, VROM, vrom_size_pow2, 0); - if (Mirroring == 2) { + if (iNESCart.mirror == 2) { ExtraNTARAM = (uint8*)FCEU_gmalloc(2048); SetupCartMirroring(4, 1, ExtraNTARAM); - } else if (Mirroring >= 0x10) - SetupCartMirroring(2 + (Mirroring & 1), 1, 0); + } else if (iNESCart.mirror >= 0x10) + SetupCartMirroring(2 + (iNESCart.mirror & 1), 1, 0); else - SetupCartMirroring(Mirroring & 1, (Mirroring & 4) >> 2, 0); + SetupCartMirroring(iNESCart.mirror & 1, (iNESCart.mirror & 4) >> 2, 0); - iNESCart.iNES2 = iNES2; - iNESCart.mapper = MapperNo; - iNESCart.submapper = subMapper; - iNESCart.battery = (head.ROM_type & 2) ? 1 : 0; - iNESCart.mirror = Mirroring; - - if (!iNES_Init(MapperNo)) { + if (!iNES_Init(iNESCart.mapper)) { FCEU_printf("\n"); - FCEU_PrintError(" iNES mapper #%d is not supported at all.\n", MapperNo); + FCEU_PrintError(" iNES mapper #%d is not supported at all.\n", iNESCart.mapper); return 0; } GameInterface = iNESGI; - if (iNES2 == 0) { + if (iNESCart.iNES2 == 0) { if (strstr(name, "(E)") || strstr(name, "(e)") || strstr(name, "(Europe)") || strstr(name, "(PAL)") || strstr(name, "(F)") || strstr(name, "(f)") || @@ -995,14 +1020,13 @@ int iNESLoad(const char *name, FCEUFILE *fp) { strstr(name, "(Sweden)") || strstr(name, "(Sw)") || strstr(name, "(Australia)") || strstr(name, "(A)") || strstr(name, "(a)")) { - region = 1; + iNESCart.region = 1; } else { - region = 0; + iNESCart.region = 0; } } - iNESCart.region = region; - switch (region) { + switch (iNESCart.region) { /* 0: RP2C02 ("NTSC NES") * 1: RP2C07 ("Licensed PAL NES") * 2: Multiple-region @@ -1059,7 +1083,7 @@ static int iNES_Init(int num) { UNIFchrrama = VROM; SetupCartCHRMapping(0, VROM, CHRRAMSize, 1); AddExState(VROM, CHRRAMSize, 0, "CHRR"); - FCEU_printf(" CHR-RAM: %3d KiB\n", CHRRAMSize / 1024); + /* FCEU_printf(" CHR-RAM: %3d KiB\n", CHRRAMSize / 1024); */ } } if (head.ROM_type & 8)