mirror of https://github.com/PCSX2/pcsx2.git
BiosTools: Allow BIOS region patching
This commit is contained in:
parent
b90de6d89f
commit
a4dcaa7c14
|
@ -34,7 +34,11 @@ BIOSSettingsWidget::BIOSSettingsWidget(SettingsDialog* dialog, QWidget* parent)
|
||||||
m_ui.setupUi(this);
|
m_ui.setupUi(this);
|
||||||
|
|
||||||
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.fastBoot, "EmuCore", "EnableFastBoot", true);
|
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.fastBoot, "EmuCore", "EnableFastBoot", true);
|
||||||
|
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.patchRegion, "EmuCore", "PatchBios", false);
|
||||||
|
SettingWidgetBinder::BindWidgetToEnumSetting(sif, m_ui.regionComboBox, "EmuCore", "PatchRegion", BiosZoneStrings, BiosZoneBytes, BiosZoneBytes[0]);
|
||||||
|
|
||||||
|
dialog->registerWidgetHelp(m_ui.patchRegion, tr("Patch Region"),tr("Unchecked"),
|
||||||
|
tr("Patches the BIOS region byte in ROM. Not recommended unless you really know what you're doing."));
|
||||||
dialog->registerWidgetHelp(m_ui.fastBoot, tr("Fast Boot"), tr("Unchecked"),
|
dialog->registerWidgetHelp(m_ui.fastBoot, tr("Fast Boot"), tr("Unchecked"),
|
||||||
tr("Patches the BIOS to skip the console's boot animation."));
|
tr("Patches the BIOS to skip the console's boot animation."));
|
||||||
|
|
||||||
|
@ -56,6 +60,9 @@ BIOSSettingsWidget::BIOSSettingsWidget(SettingsDialog* dialog, QWidget* parent)
|
||||||
connect(m_ui.openSearchDirectory, &QPushButton::clicked, this, &BIOSSettingsWidget::openSearchDirectory);
|
connect(m_ui.openSearchDirectory, &QPushButton::clicked, this, &BIOSSettingsWidget::openSearchDirectory);
|
||||||
connect(m_ui.refresh, &QPushButton::clicked, this, &BIOSSettingsWidget::refreshList);
|
connect(m_ui.refresh, &QPushButton::clicked, this, &BIOSSettingsWidget::refreshList);
|
||||||
connect(m_ui.fileList, &QTreeWidget::currentItemChanged, this, &BIOSSettingsWidget::listItemChanged);
|
connect(m_ui.fileList, &QTreeWidget::currentItemChanged, this, &BIOSSettingsWidget::listItemChanged);
|
||||||
|
|
||||||
|
connect(m_ui.patchRegion, &QCheckBox::clicked, this, [&] { m_ui.regionComboBox->setEnabled(m_ui.patchRegion->isChecked()); });
|
||||||
|
m_ui.regionComboBox->setEnabled(m_ui.patchRegion->isChecked());
|
||||||
}
|
}
|
||||||
|
|
||||||
BIOSSettingsWidget::~BIOSSettingsWidget()
|
BIOSSettingsWidget::~BIOSSettingsWidget()
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>618</width>
|
<width>618</width>
|
||||||
<height>408</height>
|
<height>439</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
@ -134,14 +134,41 @@
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Options and Patches</string>
|
<string>Options and Patches</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QGridLayout" name="gridLayout_3">
|
||||||
<item>
|
<item row="1" column="0">
|
||||||
|
<widget class="QCheckBox" name="patchRegion">
|
||||||
|
<property name="text">
|
||||||
|
<string>Patch Region</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
<widget class="QCheckBox" name="fastBoot">
|
<widget class="QCheckBox" name="fastBoot">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Fast Boot</string>
|
<string>Fast Boot</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QComboBox" name="regionComboBox">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="2">
|
||||||
|
<spacer name="horizontalSpacer_2">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|
|
@ -938,6 +938,7 @@ struct Pcsx2Config
|
||||||
#endif
|
#endif
|
||||||
// when enabled uses BOOT2 injection, skipping sony bios splashes
|
// when enabled uses BOOT2 injection, skipping sony bios splashes
|
||||||
UseBOOT2Injection : 1,
|
UseBOOT2Injection : 1,
|
||||||
|
PatchBios : 1,
|
||||||
BackupSavestate : 1,
|
BackupSavestate : 1,
|
||||||
SavestateZstdCompression : 1,
|
SavestateZstdCompression : 1,
|
||||||
// enables simulated ejection of memory cards when loading savestates
|
// enables simulated ejection of memory cards when loading savestates
|
||||||
|
@ -970,6 +971,8 @@ struct Pcsx2Config
|
||||||
|
|
||||||
FilenameOptions BaseFilenames;
|
FilenameOptions BaseFilenames;
|
||||||
|
|
||||||
|
std::string PatchRegion;
|
||||||
|
|
||||||
// Memorycard options - first 2 are default slots, last 6 are multitap 1 and 2
|
// Memorycard options - first 2 are default slots, last 6 are multitap 1 and 2
|
||||||
// slots (3 each)
|
// slots (3 each)
|
||||||
McdOptions Mcd[8];
|
McdOptions Mcd[8];
|
||||||
|
|
|
@ -1059,6 +1059,8 @@ void Pcsx2Config::LoadSave(SettingsWrapper& wrap)
|
||||||
#endif
|
#endif
|
||||||
SettingsWrapBitBool(ConsoleToStdio);
|
SettingsWrapBitBool(ConsoleToStdio);
|
||||||
SettingsWrapBitBool(HostFs);
|
SettingsWrapBitBool(HostFs);
|
||||||
|
SettingsWrapBitBool(PatchBios);
|
||||||
|
SettingsWrapEntry(PatchRegion);
|
||||||
|
|
||||||
SettingsWrapBitBool(BackupSavestate);
|
SettingsWrapBitBool(BackupSavestate);
|
||||||
SettingsWrapBitBool(SavestateZstdCompression);
|
SettingsWrapBitBool(SavestateZstdCompression);
|
||||||
|
@ -1181,6 +1183,7 @@ void Pcsx2Config::CopyConfig(const Pcsx2Config& cfg)
|
||||||
Trace = cfg.Trace;
|
Trace = cfg.Trace;
|
||||||
BaseFilenames = cfg.BaseFilenames;
|
BaseFilenames = cfg.BaseFilenames;
|
||||||
Framerate = cfg.Framerate;
|
Framerate = cfg.Framerate;
|
||||||
|
|
||||||
for (u32 i = 0; i < sizeof(Mcd) / sizeof(Mcd[0]); i++)
|
for (u32 i = 0; i < sizeof(Mcd) / sizeof(Mcd[0]); i++)
|
||||||
{
|
{
|
||||||
// Type will be File here, even if it's a folder, so we preserve the old value.
|
// Type will be File here, even if it's a folder, so we preserve the old value.
|
||||||
|
@ -1202,6 +1205,8 @@ void Pcsx2Config::CopyConfig(const Pcsx2Config& cfg)
|
||||||
EnableRecordingTools = cfg.EnableRecordingTools;
|
EnableRecordingTools = cfg.EnableRecordingTools;
|
||||||
#endif
|
#endif
|
||||||
UseBOOT2Injection = cfg.UseBOOT2Injection;
|
UseBOOT2Injection = cfg.UseBOOT2Injection;
|
||||||
|
PatchBios = cfg.PatchBios;
|
||||||
|
PatchRegion = cfg.PatchRegion;
|
||||||
BackupSavestate = cfg.BackupSavestate;
|
BackupSavestate = cfg.BackupSavestate;
|
||||||
McdEnableEjection = cfg.McdEnableEjection;
|
McdEnableEjection = cfg.McdEnableEjection;
|
||||||
McdFolderAutoManage = cfg.McdFolderAutoManage;
|
McdFolderAutoManage = cfg.McdFolderAutoManage;
|
||||||
|
|
|
@ -511,6 +511,7 @@ bool VMManager::ApplyBootParameters(const VMBootParameters& params)
|
||||||
{
|
{
|
||||||
const bool default_fast_boot = Host::GetBoolSettingValue("EmuCore", "EnableFastBoot", true);
|
const bool default_fast_boot = Host::GetBoolSettingValue("EmuCore", "EnableFastBoot", true);
|
||||||
EmuConfig.UseBOOT2Injection = params.fast_boot.value_or(default_fast_boot);
|
EmuConfig.UseBOOT2Injection = params.fast_boot.value_or(default_fast_boot);
|
||||||
|
|
||||||
s_elf_override = params.elf_override;
|
s_elf_override = params.elf_override;
|
||||||
s_disc_path.clear();
|
s_disc_path.clear();
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,7 @@ std::string BiosDescription;
|
||||||
std::string BiosZone;
|
std::string BiosZone;
|
||||||
std::string BiosPath;
|
std::string BiosPath;
|
||||||
BiosDebugInformation CurrentBiosInformation;
|
BiosDebugInformation CurrentBiosInformation;
|
||||||
|
s64 BiosRegionOffset = 0;
|
||||||
|
|
||||||
static bool LoadBiosVersion(std::FILE* fp, u32& version, std::string& description, u32& region, std::string& zone)
|
static bool LoadBiosVersion(std::FILE* fp, u32& version, std::string& description, u32& region, std::string& zone)
|
||||||
{
|
{
|
||||||
|
@ -90,19 +91,25 @@ static bool LoadBiosVersion(std::FILE* fp, u32& version, std::string& descriptio
|
||||||
switch (romver[4])
|
switch (romver[4])
|
||||||
{
|
{
|
||||||
// clang-format off
|
// clang-format off
|
||||||
case 'T': zone = "T10K"; region = 0; break;
|
case 'T': region = 0; break;
|
||||||
case 'X': zone = "Test"; region = 1; break;
|
case 'X': region = 1; break;
|
||||||
case 'J': zone = "Japan"; region = 2; break;
|
case 'J': region = 2; break;
|
||||||
case 'A': zone = "USA"; region = 3; break;
|
case 'A': region = 3; break;
|
||||||
case 'E': zone = "Europe"; region = 4; break;
|
case 'E': region = 4; break;
|
||||||
case 'H': zone = "HK"; region = 5; break;
|
case 'H': region = 5; break;
|
||||||
case 'P': zone = "Free"; region = 6; break;
|
case 'P': region = 6; break;
|
||||||
case 'C': zone = "China"; region = 7; break;
|
case 'C': region = 7; break;
|
||||||
// clang-format on
|
// clang-format on
|
||||||
default:
|
}
|
||||||
zone.clear();
|
|
||||||
zone += romver[4];
|
if (region >= 0 && region <= 7)
|
||||||
break;
|
{
|
||||||
|
zone = BiosZoneStrings[region];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
zone.clear();
|
||||||
|
zone += romver[4];
|
||||||
}
|
}
|
||||||
|
|
||||||
char vermaj[3] = {romver[0], romver[1], 0};
|
char vermaj[3] = {romver[0], romver[1], 0};
|
||||||
|
@ -119,6 +126,7 @@ static bool LoadBiosVersion(std::FILE* fp, u32& version, std::string& descriptio
|
||||||
version = strtol(vermaj, (char**)NULL, 0) << 8;
|
version = strtol(vermaj, (char**)NULL, 0) << 8;
|
||||||
version |= strtol(vermin, (char**)NULL, 0);
|
version |= strtol(vermin, (char**)NULL, 0);
|
||||||
foundRomVer = true;
|
foundRomVer = true;
|
||||||
|
BiosRegionOffset = fileOffset;
|
||||||
|
|
||||||
Console.WriteLn("Bios Found: %s", description.c_str());
|
Console.WriteLn("Bios Found: %s", description.c_str());
|
||||||
}
|
}
|
||||||
|
@ -287,6 +295,13 @@ bool LoadBIOS()
|
||||||
ChecksumIt(BiosChecksum, eeMem->ROM);
|
ChecksumIt(BiosChecksum, eeMem->ROM);
|
||||||
BiosPath = std::move(path);
|
BiosPath = std::move(path);
|
||||||
|
|
||||||
|
// Patch the region
|
||||||
|
if (EmuConfig.PatchBios)
|
||||||
|
{
|
||||||
|
eeMem->ROM[BiosRegionOffset + 4] = EmuConfig.PatchRegion[0];
|
||||||
|
Console.WriteLn("Patching ROM with region code %c", EmuConfig.PatchRegion[0]);
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef PCSX2_CORE
|
#ifndef PCSX2_CORE
|
||||||
Console.SetTitle(StringUtil::UTF8StringToWxString(StringUtil::StdStringFromFormat("Running BIOS (%s v%u.%u)",
|
Console.SetTitle(StringUtil::UTF8StringToWxString(StringUtil::StdStringFromFormat("Running BIOS (%s v%u.%u)",
|
||||||
BiosZone.c_str(), BiosVersion >> 8, BiosVersion & 0xff)));
|
BiosZone.c_str(), BiosVersion >> 8, BiosVersion & 0xff)));
|
||||||
|
|
|
@ -28,6 +28,23 @@ struct BiosDebugInformation
|
||||||
u32 threadListAddr;
|
u32 threadListAddr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const char* BiosZoneStrings[] {
|
||||||
|
"T10K",
|
||||||
|
"Test",
|
||||||
|
"Japan",
|
||||||
|
"USA",
|
||||||
|
"Europe",
|
||||||
|
"HK",
|
||||||
|
"Free",
|
||||||
|
"China",
|
||||||
|
nullptr
|
||||||
|
};
|
||||||
|
|
||||||
|
static const char* BiosZoneBytes[]
|
||||||
|
{
|
||||||
|
"T", "X", "J", "A", "E", "H", "P", "C", nullptr
|
||||||
|
};
|
||||||
|
|
||||||
extern BiosDebugInformation CurrentBiosInformation;
|
extern BiosDebugInformation CurrentBiosInformation;
|
||||||
extern u32 BiosVersion; // Used by CDVD
|
extern u32 BiosVersion; // Used by CDVD
|
||||||
extern u32 BiosRegion; // Used by CDVD
|
extern u32 BiosRegion; // Used by CDVD
|
||||||
|
@ -41,4 +58,3 @@ extern std::string BiosPath;
|
||||||
extern bool LoadBIOS();
|
extern bool LoadBIOS();
|
||||||
extern bool IsBIOS(const char* filename, u32& version, std::string& description, u32& region, std::string& zone);
|
extern bool IsBIOS(const char* filename, u32& version, std::string& description, u32& region, std::string& zone);
|
||||||
extern bool IsBIOSAvailable(const std::string& full_path);
|
extern bool IsBIOSAvailable(const std::string& full_path);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue