From f73df85d1c66b1b2f028a5aec4ebc04874863b8f Mon Sep 17 00:00:00 2001 From: Arisotura Date: Thu, 18 Nov 2021 18:17:48 +0100 Subject: make external-BIOS toggle also explicitly control external firmware make things a tad more consistent and explicit --- src/SPI.cpp | 67 ++++++----- src/frontend/Util_ROM.cpp | 2 + src/frontend/qt_sdl/EmuSettingsDialog.cpp | 6 +- src/frontend/qt_sdl/EmuSettingsDialog.ui | 166 ++++++++++++++------------ src/frontend/qt_sdl/FirmwareSettingsDialog.ui | 11 +- 5 files changed, 143 insertions(+), 109 deletions(-) (limited to 'src') diff --git a/src/SPI.cpp b/src/SPI.cpp index e8a7d35..7db04e2 100644 --- a/src/SPI.cpp +++ b/src/SPI.cpp @@ -143,18 +143,16 @@ void LoadFirmwareFromFile(FILE* f) fseek(f, 0, SEEK_SET); fread(Firmware, 1, FirmwareLength, f); - fclose(f); - // take a backup std::string fwBackupPath = FirmwarePath + ".bak"; - f = Platform::OpenLocalFile(fwBackupPath, "rb"); - if (!f) + FILE* bf = Platform::OpenLocalFile(fwBackupPath, "rb"); + if (!bf) { - f = Platform::OpenLocalFile(fwBackupPath, "wb"); - if (f) + bf = Platform::OpenLocalFile(fwBackupPath, "wb"); + if (bf) { - fwrite(Firmware, 1, FirmwareLength, f); - fclose(f); + fwrite(Firmware, 1, FirmwareLength, bf); + fclose(bf); } else { @@ -163,7 +161,7 @@ void LoadFirmwareFromFile(FILE* f) } else { - fclose(f); + fclose(bf); } } @@ -197,22 +195,32 @@ void LoadUserSettingsFromConfig() void Reset() { if (Firmware) delete[] Firmware; - Firmware = NULL; - - if (NDS::ConsoleType == 1) - FirmwarePath = Platform::GetConfigString(Platform::DSi_FirmwarePath); - else - FirmwarePath = Platform::GetConfigString(Platform::FirmwarePath); + Firmware = nullptr; + FirmwarePath = ""; - FILE* f = Platform::OpenLocalFile(FirmwarePath, "rb"); - if (!f) + if (Platform::GetConfigBool(Platform::ExternalBIOSEnable)) { - printf("Firmware not found! Generating default firmware.\n"); - LoadDefaultFirmware(); + if (NDS::ConsoleType == 1) + FirmwarePath = Platform::GetConfigString(Platform::DSi_FirmwarePath); + else + FirmwarePath = Platform::GetConfigString(Platform::FirmwarePath); + + FILE* f = Platform::OpenLocalFile(FirmwarePath, "rb"); + if (!f) + { + printf("Firmware not found! Generating default firmware.\n"); + FirmwarePath = ""; + } + else + { + LoadFirmwareFromFile(f); + fclose(f); + } } - else + + if (FirmwarePath.empty()) { - LoadFirmwareFromFile(f); + LoadDefaultFirmware(); } FirmwareMask = FirmwareLength - 1; @@ -226,7 +234,7 @@ void Reset() UserSettings = userdata; - if (!f || Platform::GetConfigBool(Platform::Firm_OverrideSettings)) + if (FirmwarePath.empty() || Platform::GetConfigBool(Platform::Firm_OverrideSettings)) LoadUserSettingsFromConfig(); // fix touchscreen coords @@ -422,13 +430,16 @@ void Write(u8 val, u32 hold) if (!hold && (CurCmd == 0x02 || CurCmd == 0x0A)) { - FILE* f = Platform::OpenLocalFile(FirmwarePath, "r+b"); - if (f) + if (!FirmwarePath.empty()) { - u32 cutoff = 0x7FA00 & FirmwareMask; - fseek(f, cutoff, SEEK_SET); - fwrite(&Firmware[cutoff], FirmwareLength-cutoff, 1, f); - fclose(f); + FILE* f = Platform::OpenLocalFile(FirmwarePath, "r+b"); + if (f) + { + u32 cutoff = 0x7FA00 & FirmwareMask; + fseek(f, cutoff, SEEK_SET); + fwrite(&Firmware[cutoff], FirmwareLength-cutoff, 1, f); + fclose(f); + } } } } diff --git a/src/frontend/Util_ROM.cpp b/src/frontend/Util_ROM.cpp index 99c7054..2fb8dac 100644 --- a/src/frontend/Util_ROM.cpp +++ b/src/frontend/Util_ROM.cpp @@ -163,6 +163,8 @@ int VerifyDSFirmware() FILE* f; long len; + if (!Config::ExternalBIOSEnable) return Load_FirmwareNotBootable; + f = Platform::OpenLocalFile(Config::FirmwarePath, "rb"); if (!f) return Load_FirmwareNotBootable; diff --git a/src/frontend/qt_sdl/EmuSettingsDialog.cpp b/src/frontend/qt_sdl/EmuSettingsDialog.cpp index 379300f..fd2ca85 100644 --- a/src/frontend/qt_sdl/EmuSettingsDialog.cpp +++ b/src/frontend/qt_sdl/EmuSettingsDialog.cpp @@ -475,6 +475,10 @@ void EmuSettingsDialog::on_chkEnableJIT_toggled() void EmuSettingsDialog::on_chkExternalBIOS_toggled() { bool disabled = !ui->chkExternalBIOS->isChecked(); - ui->txtBIOS7Path->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); } diff --git a/src/frontend/qt_sdl/EmuSettingsDialog.ui b/src/frontend/qt_sdl/EmuSettingsDialog.ui index 2a94ffa..465c38c 100644 --- a/src/frontend/qt_sdl/EmuSettingsDialog.ui +++ b/src/frontend/qt_sdl/EmuSettingsDialog.ui @@ -7,7 +7,7 @@ 0 0 575 - 351 + 370 @@ -191,8 +191,11 @@ + + <html><head/><body><p>Allows using external user-provided BIOS and firmware dumps.</p></body></html> + - Use external BIOS files + Use external BIOS/firmware files @@ -203,28 +206,31 @@ DSi-mode - - + + + + <html><head/><body><p>Make the emulated SD card read-only.</p></body></html> + - DSi ARM9 BIOS: + Read-only SD - - - - <html><head/><body><p>DSi-mode firmware (used for DS-mode backwards compatibility)</p><p><br/></p><p>Size should be 128 KB</p></body></html> + + + + Browse... - - - - <html><head/><body><p>DSi-mode ARM7 BIOS</p><p><br/></p><p>Size should be 64 KB</p></body></html> + + + + - + <html><head/><body><p>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.</p></body></html> @@ -234,90 +240,77 @@ - - - - Browse... + + + + <html><head/><body><p>Size of the SD image.</p><p><br/></p><p>If set to Auto:</p><p>* if an image file exists, the volume size will be that of the image file</p><p>* if no image file exists and folder sync is enabled, the volume size will be determined from the synced folder's contents</p><p>* otherwise, the volume size will default to 512 MB</p></body></html> - - + + - <html><head/><body><p>SD image file for emulating the DSi's SD card. A blank image file will be created if it doesn't already exist.</p></body></html> + <html><head/><body><p>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.</p></body></html> - - + + - SD card image: - - - - - - - <html><head/><body><p>Size of the SD image.</p><p><br/></p><p>If set to Auto:</p><p>* if an image file exists, the volume size will be that of the image file</p><p>* if no image file exists and folder sync is enabled, the volume size will be determined from the synced folder's contents</p><p>* otherwise, the volume size will default to 512 MB</p></body></html> + DSi firmware: - - + + - Image size: + Browse... - - + + - Browse... + DSi ARM7 BIOS: - - - - DSi NAND: + + + + <html><head/><body><p>DSi NAND dump</p><p><br/></p><p>Should have 'nocash footer' at the end</p></body></html> - - + + - <html><head/><body><p>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.</p></body></html> + <html><head/><body><p>SD image file for emulating the DSi's SD card. A blank image file will be created if it doesn't already exist.</p></body></html> - + - <html><head/><body><p>DSi NAND dump</p><p><br/></p><p>Should have 'nocash footer' at the end</p></body></html> + <html><head/><body><p>DSi-mode firmware (used for DS-mode backwards compatibility)</p><p><br/></p><p>Size should be 128 KB</p></body></html> - - + + - Browse... + DSi ARM9 BIOS: - - - - - 0 - 0 - - - - <html><head/><body><p>DSi-mode ARM9 BIOS</p><p><br/></p><p>Size should be 64 KB</p></body></html> + + + + Image size: - + <html><head/><body><p>Simulate a SD card being inserted in the DSi's SD slot.</p></body></html> @@ -327,55 +320,72 @@ - - + + - DSi firmware: + Browse... - + Browse... - - + + - <html><head/><body><p>Make the emulated SD card read-only.</p></body></html> + <html><head/><body><p>DSi-mode ARM7 BIOS</p><p><br/></p><p>Size should be 64 KB</p></body></html> + + + + - Read-only SD + SD card image: - - + + Browse... - - + + - DSi ARM7 BIOS: + DSi NAND: - - + + + + + 0 + 0 + + + + <html><head/><body><p>DSi-mode ARM9 BIOS</p><p><br/></p><p>Size should be 64 KB</p></body></html> + + + + + Browse... - - + + - + DSi mode requires external DSi BIOS/firmware/NAND diff --git a/src/frontend/qt_sdl/FirmwareSettingsDialog.ui b/src/frontend/qt_sdl/FirmwareSettingsDialog.ui index b079429..6377e94 100644 --- a/src/frontend/qt_sdl/FirmwareSettingsDialog.ui +++ b/src/frontend/qt_sdl/FirmwareSettingsDialog.ui @@ -63,7 +63,14 @@ - + + + dd/MM + + + true + + @@ -88,7 +95,7 @@ - Override firmware settings + Override settings from external firmware -- cgit v1.2.3