From 90a4025bcc6ad8cf5e6935883de8bec0199112ff Mon Sep 17 00:00:00 2001 From: AKuHAK <621640+AKuHAK@users.noreply.github.com> Date: Tue, 22 Nov 2022 17:39:44 +0200 Subject: [PATCH] BiosTools: improve region codes Region code numbering now matches regions inside CDVD_internal.h Added region assignment for non-standard romver Renamed HK region to Asia as 'H' covers not only Hong Kong, but also Korea and Taiwan --- pcsx2-qt/Settings/BIOSSettingsWidget.cpp | 28 ++++++++++++++------- pcsx2/CDVD/CDVD_internal.h | 23 +++++++++-------- pcsx2/System.cpp | 5 ++++ pcsx2/ps2/BiosTools.cpp | 32 ++++++++++++++++++------ 4 files changed, 61 insertions(+), 27 deletions(-) diff --git a/pcsx2-qt/Settings/BIOSSettingsWidget.cpp b/pcsx2-qt/Settings/BIOSSettingsWidget.cpp index 32c6694c44..d4c2ccb5e5 100644 --- a/pcsx2-qt/Settings/BIOSSettingsWidget.cpp +++ b/pcsx2-qt/Settings/BIOSSettingsWidget.cpp @@ -85,29 +85,39 @@ void BIOSSettingsWidget::listRefreshed(const QVector& items) switch (bi.region) { - case 2: // Japan + case 0: // Japan item->setIcon(0, QIcon(QStringLiteral("%1/icons/flags/NTSC-J.png").arg(res_path))); break; - case 3: // USA + case 1: // USA item->setIcon(0, QIcon(QStringLiteral("%1/icons/flags/NTSC-U.png").arg(res_path))); break; - case 4: // Europe + case 2: // Europe item->setIcon(0, QIcon(QStringLiteral("%1/icons/flags/PAL-E.png").arg(res_path))); break; - case 7: // China - item->setIcon(0, QIcon(QStringLiteral("%1/icons//flags/NTSC-C.png").arg(res_path))); + case 3: // Oceania + item->setIcon(0, QIcon(QStringLiteral("%1/icons/flags/PAL-A.png").arg(res_path))); break; - case 5: // HK + case 4: // Asia item->setIcon(0, QIcon(QStringLiteral("%1/icons/flags/NTSC-HK.png").arg(res_path))); break; - case 6: // Free - case 0: // T10K - case 1: // Test + case 5: // Russia + item->setIcon(0, QIcon(QStringLiteral("%1/icons/flags/PAL-R.png").arg(res_path))); + break; + + case 6: // China + item->setIcon(0, QIcon(QStringLiteral("%1/icons/flags/NTSC-C.png").arg(res_path))); + break; + + case 7: // Mexico, flag is missing + + case 8: // T10K + case 9: // Test + case 10: // Free default: item->setIcon(0, QIcon(QStringLiteral("%1/icons/flags/NTSC-J.png").arg(res_path))); break; diff --git a/pcsx2/CDVD/CDVD_internal.h b/pcsx2/CDVD/CDVD_internal.h index bce277d6e2..97e28cc379 100644 --- a/pcsx2/CDVD/CDVD_internal.h +++ b/pcsx2/CDVD/CDVD_internal.h @@ -277,14 +277,17 @@ static NVMLayout nvmlayouts[NVM_FORMAT_MAX] = {0x146, 0x270, 0x2B0, 0x200, 0x1C8, 0x1E0, 0x1B0, 0x180, 0x198}, // eeproms from bios v1.70 and up }; -static u8 biosLangDefaults[8][16] = -{ - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // T10K (Japanese, generally gets overridden) - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // Test (Japanese, as above) - {0x20, 0x20, 0x80, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30}, // Japan (Japanese) - {0x30, 0x21, 0x80, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41}, // USA (English) - {0x30, 0x21, 0x80, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41}, // Europe (English) - {0x30, 0x21, 0x80, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41}, // HongKong (English) - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // Free (Japanese, no examples to use) - {0x30, 0x2B, 0x80, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4B}, // China (Simplified Chinese) +static u8 biosLangDefaults[11][16] = + { + {0x20, 0x20, 0x80, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30}, // Japan (Japanese) + {0x30, 0x21, 0x80, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41}, // USA (English) + {0x30, 0x21, 0x80, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41}, // Europe (English) + {0x30, 0x21, 0x80, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41}, // Oceania (English) + {0x30, 0x21, 0x80, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41}, // Asia (English) + {0x30, 0x21, 0x80, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41}, // Russia (English) + {0x30, 0x2B, 0x80, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4B}, // China (Simplified Chinese) + {0x30, 0x21, 0x80, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41}, // Mexico (English) + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // T10K (Japanese, generally gets overridden) + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // Test (Japanese, as above) + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // Free (Japanese, no examples to use) }; diff --git a/pcsx2/System.cpp b/pcsx2/System.cpp index 3ffef40929..63dc906bf9 100644 --- a/pcsx2/System.cpp +++ b/pcsx2/System.cpp @@ -435,6 +435,11 @@ std::string SysGetBiosDiscID() // FIXME: we should return a serial based on // the BIOS being run (either a checksum of the BIOS roms, and/or a string based on BIOS // region and revision). + // Good candidate can be first part of EXTINFO data in the BIOS rom: + // Example for romver 0160EC20010704 + // 20010704-160707,ROMconf,PS20160EC20010704.bin,kuma@rom-server/~/f10k/g/app/rom + // 20010704-160707 can be used as unique ID for Bios + // rom0:EXTINFO first 15 bytes return {}; } diff --git a/pcsx2/ps2/BiosTools.cpp b/pcsx2/ps2/BiosTools.cpp index ab34457a8e..ea97cdba28 100644 --- a/pcsx2/ps2/BiosTools.cpp +++ b/pcsx2/ps2/BiosTools.cpp @@ -88,21 +88,37 @@ static bool LoadBiosVersion(std::FILE* fp, u32& version, std::string& descriptio break; } + // TODO: some regions can be detected only from rom1 + /* + switch (rom1:DVDID[4]) + { + // clang-format off + case 'O': zone = "Oceania";region = 3; break; + case 'R': zone = "Russia"; region = 5; break; + case 'M': zone = "Mexico"; region = 7; break; + // clang-format on + } + */ + switch (romver[4]) { // clang-format off - case 'T': zone = "T10K"; region = 0; break; - case 'X': zone = "Test"; region = 1; break; - case 'J': zone = "Japan"; region = 2; break; - case 'A': zone = "USA"; region = 3; break; - case 'E': zone = "Europe"; region = 4; break; - case 'H': zone = "HK"; region = 5; break; - case 'P': zone = "Free"; region = 6; break; - case 'C': zone = "China"; region = 7; break; + case 'J': zone = "Japan"; region = 0; break; + case 'A': zone = "USA"; region = 1; break; + case 'E': zone = "Europe"; region = 2; break; + // case 'E': zone = "Oceania";region = 3; break; // Not implemented + case 'H': zone = "Asia"; region = 4; break; + // case 'E': zone = "Russia"; region = 3; break; // Not implemented + case 'C': zone = "China"; region = 6; break; + // case 'A': zone = "Mexico"; region = 7; break; // Not implemented + case 'T': zone = "T10K"; region = 8; break; + case 'X': zone = "Test"; region = 9; break; + case 'P': zone = "Free"; region = 10; break; // clang-format on default: zone.clear(); zone += romver[4]; + region = 0; break; }