From f9cc11c565991c62d2c2c2fd8d258be918c929c2 Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Sun, 1 Mar 2020 20:18:26 +0800 Subject: [PATCH 1/2] Update ines-correct.h - override some mapper 27 roms to use mapper 23 --- src/ines-correct.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ines-correct.h b/src/ines-correct.h index 3fda31e..bc7b71f 100644 --- a/src/ines-correct.h +++ b/src/ines-correct.h @@ -106,6 +106,9 @@ {0x33b899c9, 16, -1}, /* Dragon Ball - Dai Maou Fukkatsu (J) [!] */ {0xa262a81f, 16, -1}, /* Rokudenashi Blues (J) */ {0x286fcd20, 21, -1}, /* Ganbare Goemon Gaiden 2 - Tenka no Zaihou (J) [!] */ + {0x335E6339, 23, -1}, /* kung fu legend (unl)[!].nes */ + {0x1A8D767B, 23, -1}, /* kung fu legend (unl)[!p].nes */ + {0x0E263D47, 23, -1}, /* World Hero (Unl) (TV System Select) [!].nes */ {0xe4a291ce, 23, -1}, /* World Hero (Unl) [!] */ {0x51e9cd33, 23, -1}, /* World Hero (Unl) [b1] */ {0x105dd586, 27, -1}, /* Mi Hun Che variations... */ From aee4669b8d135b5d8aca1112883ce65bd43ad2d9 Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Sun, 1 Mar 2020 23:17:30 +0800 Subject: [PATCH 2/2] Better detection of mapper numbers based on NES header version --- src/ines.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/ines.c b/src/ines.c index 80f2b59..2f2ceca 100644 --- a/src/ines.c +++ b/src/ines.c @@ -808,12 +808,24 @@ int iNESLoad(const char *name, FCEUFILE *fp) { memset((char*)(&head) + 0xA, 0, 0x6); } - subMapper = 0; - MapperNo = (head.ROM_type >> 4) | (head.ROM_type2 & 0xF0); + /* 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; - iNES2 = ((head.ROM_type2 & 0x0C) == 0x08) ? 1 : 0; + subMapper = 0; if (iNES2) { MapperNo |= ((uint32)head.ROM_type3 << 8) & 0xF00;