N64: Add CIC5101 type. Don't analyze gameboy roms. (#843)
* Squashed commit of the following:
commit 40c58abf1d87e870d20ab77bf2934df6ed6d7b94
Merge: 1fc9c37 7c65b22
Author: Rikard Bengtsson <rikard@loginhasselberg.se>
Date: Fri Oct 6 09:00:07 2023 +0200
Merge branch 'master' of https://github.com/yxkalle/Main_MiSTer
commit 1fc9c37c070b54719aa6ae14890db5fc6bcec3e1
Author: Rikard Bengtsson <rikard.bengtsson@yahoo.se>
Date: Fri Oct 6 08:57:57 2023 +0200
N64: Just some cleanup. Made code simpler. Added some comments where needed.
commit 7c65b22cab1a33f599b3a7ecb2faaaa27613046b
Author: Rikard Bengtsson <rikard@loginhasselberg.se>
Date: Fri Oct 6 04:09:51 2023 +0200
Delete MiSTer_noface
commit fe2169544f5ce5ace125109bf65df16dc65594a2
Merge: c163956 ee5659a
Author: Rikard Bengtsson <rikard.bengtsson@yahoo.se>
Date: Fri Oct 6 03:28:02 2023 +0200
Merge branch 'master' into add-id-to-db
commit c1639563da1ea714575f51f27a21df9c2f493a6e
Author: Rikard Bengtsson <rikard@loginhasselberg.se>
Date: Fri Oct 6 03:15:05 2023 +0200
Update n64.cpp
commit f4a6b98b5dd650bc13e08db8bb21e3da31fea64b
Author: Rikard Bengtsson <rikard@loginhasselberg.se>
Date: Fri Oct 6 03:12:51 2023 +0200
cleanup
commit 401b9dc6a9b2d0dd06c18be1e48014b3dc81e946
Author: Rikard Bengtsson <rikard@loginhasselberg.se>
Date: Tue Oct 3 22:48:03 2023 +0200
Clean-up
Clean-up the code, added some comments. Allow uppercase md5s in the database.
commit e0e2affdfe277577820ba73a202b06311b645ec7
Author: Rikard Bengtsson <rikard@loginhasselberg.se>
Date: Mon Oct 2 20:05:28 2023 +0200
Cleaner code?
commit 554666832bd55d924b531f469a45cb7996f13e03
Author: Rikard Bengtsson <rikard@loginhasselberg.se>
Date: Sun Oct 1 02:13:00 2023 +0200
Delete N64-database.txt
Delete before PR
commit 9e8fc3f30c36ea9de59d4f1801a4341edbf73eb8
Author: Rikard Bengtsson <rikard@loginhasselberg.se>
Date: Sun Oct 1 02:09:07 2023 +0200
Some commenting and clean-up
commit be19bb6e679cd76d32f9b0382c08052ba1e68944
Author: Rikard Bengtsson <rikard@loginhasselberg.se>
Date: Sun Oct 1 01:19:05 2023 +0200
Autodetect settings by ID
Settings are saved in the database text files as usual, but you can match by both MD5 (first 4096), MD5 (full) as well as ID + region + revision.
* Added support for hacked boot codes
* Update n64.cpp
This commit is contained in:
@@ -45,7 +45,8 @@ enum class CIC {
|
||||
CIC_NUS_8303,
|
||||
CIC_NUS_8401,
|
||||
CIC_NUS_5167,
|
||||
CIC_NUS_DDUS
|
||||
CIC_NUS_DDUS,
|
||||
CIC_NUS_5101
|
||||
};
|
||||
|
||||
enum class SystemType {
|
||||
@@ -58,12 +59,12 @@ enum class RomFormat {
|
||||
UNKNOWN = 0,
|
||||
BIG_ENDIAN,
|
||||
BYTE_SWAPPED,
|
||||
LITTLE_ENDIAN,
|
||||
LITTLE_ENDIAN
|
||||
};
|
||||
|
||||
enum class AutoDetect {
|
||||
ON = 0,
|
||||
OFF = 1,
|
||||
OFF = 1
|
||||
};
|
||||
|
||||
static RomFormat detectRomFormat(const uint8_t* data) {
|
||||
@@ -82,6 +83,9 @@ static RomFormat detectRomFormat(const uint8_t* data) {
|
||||
|
||||
static void normalizeData(uint8_t* data, size_t size, RomFormat format) {
|
||||
switch(format) {
|
||||
default:
|
||||
// nothing to do
|
||||
break;
|
||||
case RomFormat::BYTE_SWAPPED:
|
||||
for (size_t i = 0; i < size; i += 2) {
|
||||
auto c0 = data[0];
|
||||
@@ -104,9 +108,6 @@ static void normalizeData(uint8_t* data, size_t size, RomFormat format) {
|
||||
data += 4;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// nothing to do
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,6 +158,7 @@ static bool parse_and_apply_db_tags(char* tags) {
|
||||
case fnv_hash("cic8401"): cic = CIC::CIC_NUS_8401; break;
|
||||
case fnv_hash("cic5167"): cic = CIC::CIC_NUS_5167; break;
|
||||
case fnv_hash("cicDDUS"): cic = CIC::CIC_NUS_DDUS; break;
|
||||
case fnv_hash("cic5101"): cic = CIC::CIC_NUS_5101; break;
|
||||
default: printf("Unknown tag: %s\n", tag); break;
|
||||
}
|
||||
}
|
||||
@@ -372,9 +374,10 @@ static bool detect_rom_settings_from_first_chunk(char region_code, uint64_t crc)
|
||||
case UINT64_C(0x000000a9df4b39e1): cic = CIC::CIC_NUS_8303; break;
|
||||
case UINT64_C(0x000000aa764e39e1): cic = CIC::CIC_NUS_8401; break;
|
||||
case UINT64_C(0x000000abb0b739e1): cic = CIC::CIC_NUS_DDUS; break;
|
||||
case UINT64_C(0x00000081ce470326): cic = CIC::CIC_NUS_5101; break;
|
||||
}
|
||||
|
||||
printf("System: %d, CIC: %d\n", (int)system_type, (int)cic);
|
||||
if (is_known_cic) printf("System: %d, CIC: %d\n", (int)system_type, (int)cic);
|
||||
printf("Auto-detect is on, updating OSD settings\n");
|
||||
|
||||
user_io_status_set("[80:79]", (uint32_t)system_type);
|
||||
@@ -410,11 +413,31 @@ int n64_rom_tx(const char* name, unsigned char index) {
|
||||
int size = bytes2send;
|
||||
if (use_progress) ProgressMessage(0, 0, 0, 0);
|
||||
|
||||
if (index > 'A') {
|
||||
// Handle non-N64 files (Game Boy)
|
||||
while (bytes2send) {
|
||||
uint32_t chunk = (bytes2send > sizeof(buf)) ? sizeof(buf) : bytes2send;
|
||||
FileReadAdv(&f, buf, chunk);
|
||||
|
||||
user_io_file_tx_data(buf, chunk);
|
||||
|
||||
if (use_progress) ProgressMessage("Loading", f.name, size - bytes2send, size);
|
||||
bytes2send -= chunk;
|
||||
}
|
||||
|
||||
printf("Done.\n");
|
||||
FileClose(&f);
|
||||
|
||||
// Signal end of transmission
|
||||
user_io_set_download(0);
|
||||
ProgressMessage(0, 0, 0, 0);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
// save state processing
|
||||
process_ss(name);
|
||||
|
||||
bool is_first_chunk = true;
|
||||
|
||||
// 0 = Nothing detected
|
||||
// 1 = System region and CIC detected
|
||||
// 2 = Found some ROM info in DB (Save type etc.), but System region and CIC has not been determined
|
||||
@@ -428,9 +451,9 @@ int n64_rom_tx(const char* name, unsigned char index) {
|
||||
char md5_hex[40];
|
||||
uint64_t bootcode_sum = 0;
|
||||
char cart_id[8];
|
||||
bool is_first_chunk = true;
|
||||
|
||||
while (bytes2send)
|
||||
{
|
||||
while (bytes2send) {
|
||||
uint32_t chunk = (bytes2send > sizeof(buf)) ? sizeof(buf) : bytes2send;
|
||||
|
||||
FileReadAdv(&f, buf, chunk);
|
||||
@@ -469,9 +492,8 @@ int n64_rom_tx(const char* name, unsigned char index) {
|
||||
printf("No ROM information found for header hash: %s\n", md5_hex);
|
||||
|
||||
// Calculate boot ROM checksum
|
||||
for (uint32_t i = 0x40 / sizeof(uint32_t); i < 0x1000 / sizeof(uint32_t); i++) {
|
||||
for (uint32_t i = 0x40 / sizeof(uint32_t); i < (buf[0x3b] == 'Z' ? 0xc00 : 0x1000) / sizeof(uint32_t); i++)
|
||||
bootcode_sum += ((uint32_t*)buf)[i];
|
||||
}
|
||||
|
||||
/* The first byte (starting at 0x3b) indicates the type of ROM
|
||||
* 'N' = cart
|
||||
@@ -511,9 +533,8 @@ int n64_rom_tx(const char* name, unsigned char index) {
|
||||
printf("No ROM information found for cart ID: %s\n", cart_id);
|
||||
// Try detect (partial) ROM settings by analyzing the ROM itself. (System region and CIC)
|
||||
if ((rom_settings_detected == 0 || rom_settings_detected == 2) &&
|
||||
detect_rom_settings_from_first_chunk(cart_id[3], bootcode_sum)) {
|
||||
detect_rom_settings_from_first_chunk(cart_id[3], bootcode_sum))
|
||||
rom_settings_detected |= 1;
|
||||
}
|
||||
}
|
||||
// Complement info found in DB with System region and CIC
|
||||
else if (rom_settings_detected == 2 &&
|
||||
|
||||
Reference in New Issue
Block a user