make external-BIOS toggle also explicitly control external firmware

make things a tad more consistent and explicit
This commit is contained in:
Arisotura 2021-11-18 18:17:48 +01:00
parent 19ddaee13b
commit f73df85d1c
5 changed files with 187 additions and 153 deletions

View File

@ -143,18 +143,16 @@ void LoadFirmwareFromFile(FILE* f)
fseek(f, 0, SEEK_SET); fseek(f, 0, SEEK_SET);
fread(Firmware, 1, FirmwareLength, f); fread(Firmware, 1, FirmwareLength, f);
fclose(f);
// take a backup // take a backup
std::string fwBackupPath = FirmwarePath + ".bak"; std::string fwBackupPath = FirmwarePath + ".bak";
f = Platform::OpenLocalFile(fwBackupPath, "rb"); FILE* bf = Platform::OpenLocalFile(fwBackupPath, "rb");
if (!f) if (!bf)
{ {
f = Platform::OpenLocalFile(fwBackupPath, "wb"); bf = Platform::OpenLocalFile(fwBackupPath, "wb");
if (f) if (bf)
{ {
fwrite(Firmware, 1, FirmwareLength, f); fwrite(Firmware, 1, FirmwareLength, bf);
fclose(f); fclose(bf);
} }
else else
{ {
@ -163,7 +161,7 @@ void LoadFirmwareFromFile(FILE* f)
} }
else else
{ {
fclose(f); fclose(bf);
} }
} }
@ -197,8 +195,11 @@ void LoadUserSettingsFromConfig()
void Reset() void Reset()
{ {
if (Firmware) delete[] Firmware; if (Firmware) delete[] Firmware;
Firmware = NULL; Firmware = nullptr;
FirmwarePath = "";
if (Platform::GetConfigBool(Platform::ExternalBIOSEnable))
{
if (NDS::ConsoleType == 1) if (NDS::ConsoleType == 1)
FirmwarePath = Platform::GetConfigString(Platform::DSi_FirmwarePath); FirmwarePath = Platform::GetConfigString(Platform::DSi_FirmwarePath);
else else
@ -208,11 +209,18 @@ void Reset()
if (!f) if (!f)
{ {
printf("Firmware not found! Generating default firmware.\n"); printf("Firmware not found! Generating default firmware.\n");
LoadDefaultFirmware(); FirmwarePath = "";
} }
else else
{ {
LoadFirmwareFromFile(f); LoadFirmwareFromFile(f);
fclose(f);
}
}
if (FirmwarePath.empty())
{
LoadDefaultFirmware();
} }
FirmwareMask = FirmwareLength - 1; FirmwareMask = FirmwareLength - 1;
@ -226,7 +234,7 @@ void Reset()
UserSettings = userdata; UserSettings = userdata;
if (!f || Platform::GetConfigBool(Platform::Firm_OverrideSettings)) if (FirmwarePath.empty() || Platform::GetConfigBool(Platform::Firm_OverrideSettings))
LoadUserSettingsFromConfig(); LoadUserSettingsFromConfig();
// fix touchscreen coords // fix touchscreen coords
@ -421,6 +429,8 @@ void Write(u8 val, u32 hold)
} }
if (!hold && (CurCmd == 0x02 || CurCmd == 0x0A)) if (!hold && (CurCmd == 0x02 || CurCmd == 0x0A))
{
if (!FirmwarePath.empty())
{ {
FILE* f = Platform::OpenLocalFile(FirmwarePath, "r+b"); FILE* f = Platform::OpenLocalFile(FirmwarePath, "r+b");
if (f) if (f)
@ -432,6 +442,7 @@ void Write(u8 val, u32 hold)
} }
} }
} }
}
} }

View File

@ -163,6 +163,8 @@ int VerifyDSFirmware()
FILE* f; FILE* f;
long len; long len;
if (!Config::ExternalBIOSEnable) return Load_FirmwareNotBootable;
f = Platform::OpenLocalFile(Config::FirmwarePath, "rb"); f = Platform::OpenLocalFile(Config::FirmwarePath, "rb");
if (!f) return Load_FirmwareNotBootable; if (!f) return Load_FirmwareNotBootable;

View File

@ -475,6 +475,10 @@ void EmuSettingsDialog::on_chkEnableJIT_toggled()
void EmuSettingsDialog::on_chkExternalBIOS_toggled() void EmuSettingsDialog::on_chkExternalBIOS_toggled()
{ {
bool disabled = !ui->chkExternalBIOS->isChecked(); bool disabled = !ui->chkExternalBIOS->isChecked();
ui->txtBIOS7Path->setDisabled(disabled);
ui->txtBIOS9Path->setDisabled(disabled); ui->txtBIOS9Path->setDisabled(disabled);
ui->btnBIOS9Browse->setDisabled(disabled);
ui->txtBIOS7Path->setDisabled(disabled);
ui->btnBIOS7Browse->setDisabled(disabled);
ui->txtFirmwarePath->setDisabled(disabled);
ui->btnFirmwareBrowse->setDisabled(disabled);
} }

View File

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>575</width> <width>575</width>
<height>351</height> <height>370</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
@ -191,8 +191,11 @@
</item> </item>
<item row="0" column="0" colspan="3"> <item row="0" column="0" colspan="3">
<widget class="QCheckBox" name="chkExternalBIOS"> <widget class="QCheckBox" name="chkExternalBIOS">
<property name="whatsThis">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Allows using external user-provided BIOS and firmware dumps.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text"> <property name="text">
<string>Use external BIOS files</string> <string>Use external BIOS/firmware files</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -203,28 +206,31 @@
<string>DSi-mode</string> <string>DSi-mode</string>
</attribute> </attribute>
<layout class="QGridLayout" name="gridLayout_2"> <layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>DSi ARM9 BIOS:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QPathInput" name="txtDSiFirmwarePath">
<property name="whatsThis">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;DSi-mode firmware (used for DS-mode backwards compatibility)&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;Size should be 128 KB&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPathInput" name="txtDSiBIOS7Path">
<property name="whatsThis">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;DSi-mode ARM7 BIOS&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;Size should be 64 KB&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="9" column="0"> <item row="9" column="0">
<widget class="QCheckBox" name="cbDSiSDReadOnly">
<property name="whatsThis">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Make the emulated SD card read-only.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Read-only SD</string>
</property>
</widget>
</item>
<item row="10" column="2">
<widget class="QPushButton" name="btnDSiSDFolderBrowse">
<property name="text">
<string>Browse...</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="3">
<widget class="QLabel" name="label_14">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="10" column="0">
<widget class="QCheckBox" name="cbDSiSDFolder"> <widget class="QCheckBox" name="cbDSiSDFolder">
<property name="whatsThis"> <property name="whatsThis">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Sync the emulated SD card to the given folder. The folder's contents will be copied to the SD image, and any change made to the SD image will be reflected to the folder.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Sync the emulated SD card to the given folder. The folder's contents will be copied to the SD image, and any change made to the SD image will be reflected to the folder.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
@ -234,77 +240,129 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="2"> <item row="8" column="1">
<widget class="QPushButton" name="btnDSiFirmwareBrowse">
<property name="text">
<string>Browse...</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QPathInput" name="txtDSiSDPath">
<property name="whatsThis">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;SD image file for emulating the DSi's SD card. A blank image file will be created if it doesn't already exist.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>SD card image:</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QComboBox" name="cbxDSiSDSize"> <widget class="QComboBox" name="cbxDSiSDSize">
<property name="whatsThis"> <property name="whatsThis">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Size of the SD image.&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;If set to Auto:&lt;/p&gt;&lt;p&gt;* if an image file exists, the volume size will be that of the image file&lt;/p&gt;&lt;p&gt;* if no image file exists and folder sync is enabled, the volume size will be determined from the synced folder's contents&lt;/p&gt;&lt;p&gt;* otherwise, the volume size will default to 512 MB&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Size of the SD image.&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;If set to Auto:&lt;/p&gt;&lt;p&gt;* if an image file exists, the volume size will be that of the image file&lt;/p&gt;&lt;p&gt;* if no image file exists and folder sync is enabled, the volume size will be determined from the synced folder's contents&lt;/p&gt;&lt;p&gt;* otherwise, the volume size will default to 512 MB&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="7" column="0"> <item row="10" column="1">
<widget class="QLabel" name="label_13">
<property name="text">
<string>Image size:</string>
</property>
</widget>
</item>
<item row="6" column="2">
<widget class="QPushButton" name="btnDSiSDBrowse">
<property name="text">
<string>Browse...</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>DSi NAND:</string>
</property>
</widget>
</item>
<item row="9" column="1">
<widget class="QLineEdit" name="txtDSiSDFolder"> <widget class="QLineEdit" name="txtDSiSDFolder">
<property name="whatsThis"> <property name="whatsThis">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Sync the emulated SD card to the given folder. The folder's contents will be copied to the SD image, and any change made to the SD image will be reflected to the folder.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Sync the emulated SD card to the given folder. The folder's contents will be copied to the SD image, and any change made to the SD image will be reflected to the folder.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="1"> <item row="3" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>DSi firmware:</string>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QPushButton" name="btnDSiFirmwareBrowse">
<property name="text">
<string>Browse...</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>DSi ARM7 BIOS:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QPathInput" name="txtDSiNANDPath"> <widget class="QPathInput" name="txtDSiNANDPath">
<property name="whatsThis"> <property name="whatsThis">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;DSi NAND dump&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;Should have 'nocash footer' at the end&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;DSi NAND dump&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;Should have 'nocash footer' at the end&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="2"> <item row="7" column="1">
<widget class="QPathInput" name="txtDSiSDPath">
<property name="whatsThis">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;SD image file for emulating the DSi's SD card. A blank image file will be created if it doesn't already exist.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QPathInput" name="txtDSiFirmwarePath">
<property name="whatsThis">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;DSi-mode firmware (used for DS-mode backwards compatibility)&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;Size should be 128 KB&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>DSi ARM9 BIOS:</string>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="label_13">
<property name="text">
<string>Image size:</string>
</property>
</widget>
</item>
<item row="6" column="0" colspan="3">
<widget class="QCheckBox" name="cbDSiSDEnable">
<property name="whatsThis">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Simulate a SD card being inserted in the DSi's SD slot.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Enable DSi SD card</string>
</property>
</widget>
</item>
<item row="7" column="2">
<widget class="QPushButton" name="btnDSiSDBrowse">
<property name="text">
<string>Browse...</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QPushButton" name="btnDSiBIOS7Browse">
<property name="text">
<string>Browse...</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QPathInput" name="txtDSiBIOS7Path">
<property name="whatsThis">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;DSi-mode ARM7 BIOS&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;Size should be 64 KB&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>SD card image:</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="btnDSiBIOS9Browse"> <widget class="QPushButton" name="btnDSiBIOS9Browse">
<property name="text"> <property name="text">
<string>Browse...</string> <string>Browse...</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1"> <item row="4" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>DSi NAND:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPathInput" name="txtDSiBIOS9Path"> <widget class="QPathInput" name="txtDSiBIOS9Path">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed"> <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
@ -317,65 +375,17 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="5" column="0" colspan="3"> <item row="4" column="2">
<widget class="QCheckBox" name="cbDSiSDEnable">
<property name="whatsThis">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Simulate a SD card being inserted in the DSi's SD slot.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Enable DSi SD card</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>DSi firmware:</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="btnDSiBIOS7Browse">
<property name="text">
<string>Browse...</string>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QCheckBox" name="cbDSiSDReadOnly">
<property name="whatsThis">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Make the emulated SD card read-only.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Read-only SD</string>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QPushButton" name="btnDSiNANDBrowse"> <widget class="QPushButton" name="btnDSiNANDBrowse">
<property name="text"> <property name="text">
<string>Browse...</string> <string>Browse...</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="0" column="0" colspan="3">
<widget class="QLabel" name="label_6"> <widget class="QLabel" name="label_15">
<property name="text"> <property name="text">
<string>DSi ARM7 BIOS:</string> <string>DSi mode requires external DSi BIOS/firmware/NAND</string>
</property>
</widget>
</item>
<item row="9" column="2">
<widget class="QPushButton" name="btnDSiSDFolderBrowse">
<property name="text">
<string>Browse...</string>
</property>
</widget>
</item>
<item row="4" column="0" colspan="3">
<widget class="QLabel" name="label_14">
<property name="text">
<string/>
</property> </property>
</widget> </widget>
</item> </item>

View File

@ -63,7 +63,14 @@
</widget> </widget>
</item> </item>
<item row="2" column="1"> <item row="2" column="1">
<widget class="QDateEdit" name="birthdayEdit"/> <widget class="QDateEdit" name="birthdayEdit">
<property name="displayFormat">
<string>dd/MM</string>
</property>
<property name="calendarPopup">
<bool>true</bool>
</property>
</widget>
</item> </item>
<item row="3" column="0"> <item row="3" column="0">
<widget class="QLabel" name="label_2"> <widget class="QLabel" name="label_2">
@ -88,7 +95,7 @@
<item row="5" column="0" colspan="2"> <item row="5" column="0" colspan="2">
<widget class="QCheckBox" name="overrideFirmwareBox"> <widget class="QCheckBox" name="overrideFirmwareBox">
<property name="text"> <property name="text">
<string>Override firmware settings</string> <string>Override settings from external firmware</string>
</property> </property>
</widget> </widget>
</item> </item>