aboutsummaryrefslogtreecommitdiff
path: root/src/frontend/qt_sdl
diff options
context:
space:
mode:
authorJesse Talavera <jesse@jesse.tg>2023-12-05 10:47:16 -0500
committerGitHub <noreply@github.com>2023-12-05 16:47:16 +0100
commit090627b3c19488e36677113e2f1ac16bdb4e2d05 (patch)
treed731b7b302801c9317c34584cdebb811b93739d0 /src/frontend/qt_sdl
parentae91d89f7c18f6b4153deeef7e3ebe14a1d849fe (diff)
Remove the last `ConfigEntry` state (#1902)
* Get rid of `ConfigEntry::ExternalBIOSEnable` - Now the BIOS files themselves are checked - The frontend's `Config::ExternalBIOSEnable` is not affected * Add `JITArgs` * Pass the JIT status to the `ARM` constructors * Encapsulate `NDS::EnableJIT` * Pass `JITArgs` to `ARMJIT`'s constructor * Remove the `JIT_*` `ConfigEntry`s in favor of members - Allow all the JIT args to be set with `NDS::SetJITArgs` - Encapsulate the JIT-related parameters in `ARMJIT` so they can reset the block cache if changed - Update the active (or newly-created) console in the frontend with adjusted JIT args * Make audio bit depth and interpolation configurable in `NDSArgs` - Define enums for both - Give those settings default values in `NDSArgs` - Remove `ConfigEntry::AudioBitDepth` - Initialize these settings in the relevant SPU constructors * Move the last DSi-specific logic in `Reset` to its own subclass * Remove `ConfigEntry::DSi_FullBIOSBoot` - Add members to `DSi` instead for getting and setting this - Update the frontend to accommodate these changes * Oops, missed a spot * Remove `ConfigEntry::Firm_MAC` and `Platform::GetConfigArray` - Also move the MAC parsing code to `ROMManager` * Remove the last `ConfigEntry` state - Make GDB support configurable via members * Add some `#ifdef`s that I'd almost forgotten
Diffstat (limited to 'src/frontend/qt_sdl')
-rw-r--r--src/frontend/qt_sdl/AudioInOut.cpp2
-rw-r--r--src/frontend/qt_sdl/Platform.cpp84
-rw-r--r--src/frontend/qt_sdl/ROMManager.cpp32
-rw-r--r--src/frontend/qt_sdl/main.cpp45
4 files changed, 74 insertions, 89 deletions
diff --git a/src/frontend/qt_sdl/AudioInOut.cpp b/src/frontend/qt_sdl/AudioInOut.cpp
index ae5529d..1f1ee1c 100644
--- a/src/frontend/qt_sdl/AudioInOut.cpp
+++ b/src/frontend/qt_sdl/AudioInOut.cpp
@@ -369,7 +369,7 @@ void UpdateSettings(NDS& nds)
{
MicClose();
- nds.SPU.SetInterpolation(Config::AudioInterp);
+ nds.SPU.SetInterpolation(static_cast<AudioInterpolation>(Config::AudioInterp));
SetupMicInputData();
MicOpen();
diff --git a/src/frontend/qt_sdl/Platform.cpp b/src/frontend/qt_sdl/Platform.cpp
index d410d4f..4630582 100644
--- a/src/frontend/qt_sdl/Platform.cpp
+++ b/src/frontend/qt_sdl/Platform.cpp
@@ -193,90 +193,6 @@ std::string InstanceFileSuffix()
return suffix;
}
-
-int GetConfigInt(ConfigEntry entry)
-{
- const int imgsizes[] = {0, 256, 512, 1024, 2048, 4096};
-
- switch (entry)
- {
-#ifdef JIT_ENABLED
- case JIT_MaxBlockSize: return Config::JIT_MaxBlockSize;
-#endif
-
- case AudioBitDepth: return Config::AudioBitDepth;
-
-#ifdef GDBSTUB_ENABLED
- case GdbPortARM7: return Config::GdbPortARM7;
- case GdbPortARM9: return Config::GdbPortARM9;
-#endif
- }
-
- return 0;
-}
-
-bool GetConfigBool(ConfigEntry entry)
-{
- switch (entry)
- {
-#ifdef JIT_ENABLED
- case JIT_Enable: return Config::JIT_Enable != 0;
- case JIT_LiteralOptimizations: return Config::JIT_LiteralOptimisations != 0;
- case JIT_BranchOptimizations: return Config::JIT_BranchOptimisations != 0;
- case JIT_FastMemory: return Config::JIT_FastMemory != 0;
-#endif
-
- case ExternalBIOSEnable: return Config::ExternalBIOSEnable != 0;
-
- case DSi_FullBIOSBoot: return Config::DSiFullBIOSBoot != 0;
-
-#ifdef GDBSTUB_ENABLED
- case GdbEnabled: return Config::GdbEnabled;
- case GdbARM7BreakOnStartup: return Config::GdbARM7BreakOnStartup;
- case GdbARM9BreakOnStartup: return Config::GdbARM9BreakOnStartup;
-#endif
- }
-
- return false;
-}
-
-bool GetConfigArray(ConfigEntry entry, void* data)
-{
- switch (entry)
- {
- case Firm_MAC:
- {
- std::string& mac_in = Config::FirmwareMAC;
- u8* mac_out = (u8*)data;
-
- int o = 0;
- u8 tmp = 0;
- for (int i = 0; i < 18; i++)
- {
- char c = mac_in[i];
- if (c == '\0') break;
-
- int n;
- if (c >= '0' && c <= '9') n = c - '0';
- else if (c >= 'a' && c <= 'f') n = c - 'a' + 10;
- else if (c >= 'A' && c <= 'F') n = c - 'A' + 10;
- else continue;
-
- if (!(o & 1))
- tmp = n;
- else
- mac_out[o >> 1] = n | (tmp << 4);
-
- o++;
- if (o >= 12) return true;
- }
- }
- return false;
- }
-
- return false;
-}
-
constexpr char AccessMode(FileMode mode, bool file_exists)
{
if (!(mode & FileMode::Write))
diff --git a/src/frontend/qt_sdl/ROMManager.cpp b/src/frontend/qt_sdl/ROMManager.cpp
index fda043a..b065ad1 100644
--- a/src/frontend/qt_sdl/ROMManager.cpp
+++ b/src/frontend/qt_sdl/ROMManager.cpp
@@ -1078,6 +1078,36 @@ pair<unique_ptr<Firmware>, string> GenerateDefaultFirmware()
return std::make_pair(std::move(firmware), std::move(wfcsettingspath));
}
+bool ParseMacAddress(void* data)
+{
+ const std::string& mac_in = Config::FirmwareMAC;
+ u8* mac_out = (u8*)data;
+
+ int o = 0;
+ u8 tmp = 0;
+ for (int i = 0; i < 18; i++)
+ {
+ char c = mac_in[i];
+ if (c == '\0') break;
+
+ int n;
+ if (c >= '0' && c <= '9') n = c - '0';
+ else if (c >= 'a' && c <= 'f') n = c - 'a' + 10;
+ else if (c >= 'A' && c <= 'F') n = c - 'A' + 10;
+ else continue;
+
+ if (!(o & 1))
+ tmp = n;
+ else
+ mac_out[o >> 1] = n | (tmp << 4);
+
+ o++;
+ if (o >= 12) return true;
+ }
+
+ return false;
+}
+
void CustomizeFirmware(Firmware& firmware) noexcept
{
auto& currentData = firmware.GetEffectiveUserData();
@@ -1136,7 +1166,7 @@ void CustomizeFirmware(Firmware& firmware) noexcept
MacAddress configuredMac;
- rep = Platform::GetConfigArray(Platform::Firm_MAC, &configuredMac);
+ rep = ParseMacAddress(&configuredMac);
rep &= (configuredMac != MacAddress());
if (rep)
diff --git a/src/frontend/qt_sdl/main.cpp b/src/frontend/qt_sdl/main.cpp
index 5bd4d1b..30ea0ab 100644
--- a/src/frontend/qt_sdl/main.cpp
+++ b/src/frontend/qt_sdl/main.cpp
@@ -222,12 +222,42 @@ std::unique_ptr<NDS> EmuThread::CreateConsole(
if (!firmware)
return nullptr;
+#ifdef JIT_ENABLED
+ JITArgs jitargs {
+ static_cast<unsigned>(Config::JIT_MaxBlockSize),
+ Config::JIT_LiteralOptimisations,
+ Config::JIT_BranchOptimisations,
+ Config::JIT_FastMemory,
+ };
+#endif
+
+#ifdef GDBSTUB_ENABLED
+ GDBArgs gdbargs {
+ static_cast<u16>(Config::GdbPortARM7),
+ static_cast<u16>(Config::GdbPortARM9),
+ Config::GdbARM7BreakOnStartup,
+ Config::GdbARM9BreakOnStartup,
+ };
+#endif
+
NDSArgs ndsargs {
std::move(ndscart),
std::move(gbacart),
*arm9bios,
*arm7bios,
std::move(*firmware),
+#ifdef JIT_ENABLED
+ Config::JIT_Enable ? std::make_optional(jitargs) : std::nullopt,
+#else
+ std::nullopt,
+#endif
+ static_cast<AudioBitDepth>(Config::AudioBitDepth),
+ static_cast<AudioInterpolation>(Config::AudioInterp),
+#ifdef GDBSTUB_ENABLED
+ Config::GdbEnabled ? std::make_optional(gdbargs) : std::nullopt,
+#else
+ std::nullopt,
+#endif
};
if (Config::ConsoleType == 1)
@@ -251,6 +281,7 @@ std::unique_ptr<NDS> EmuThread::CreateConsole(
*arm7ibios,
std::move(*nand),
std::move(sdcard),
+ Config::DSiFullBIOSBoot,
};
args.GBAROM = nullptr;
@@ -339,6 +370,7 @@ bool EmuThread::UpdateConsole(UpdateConsoleNDSArgs&& ndsargs, UpdateConsoleGBAAr
auto dsisdcard = ROMManager::LoadDSiSDCard();
+ dsi.SetFullBIOSBoot(Config::DSiFullBIOSBoot);
dsi.ARM7iBIOS = *arm7ibios;
dsi.ARM9iBIOS = *arm9ibios;
dsi.SetNAND(std::move(*nandimage));
@@ -354,10 +386,19 @@ bool EmuThread::UpdateConsole(UpdateConsoleNDSArgs&& ndsargs, UpdateConsoleGBAAr
NDS->SetGBACart(std::move(nextgbacart));
}
+ JITArgs jitargs {
+ static_cast<unsigned>(Config::JIT_MaxBlockSize),
+ Config::JIT_LiteralOptimisations,
+ Config::JIT_BranchOptimisations,
+ Config::JIT_FastMemory,
+ };
NDS->ARM7BIOS = *arm7bios;
NDS->ARM9BIOS = *arm9bios;
NDS->SetFirmware(std::move(*firmware));
NDS->SetNDSCart(std::move(nextndscart));
+ NDS->SetJITArgs(Config::JIT_Enable ? std::make_optional(jitargs) : std::nullopt);
+ NDS->SPU.SetInterpolation(static_cast<AudioInterpolation>(Config::AudioInterp));
+ NDS->SPU.SetDegrade10Bit(static_cast<AudioBitDepth>(Config::AudioBitDepth));
NDS::Current = NDS.get();
@@ -510,8 +551,6 @@ void EmuThread::run()
NDS->GPU.SetRenderer3D(std::move(glrenderer));
}
- NDS->SPU.SetInterpolation(Config::AudioInterp);
-
Input::Init();
u32 nframes = 0;
@@ -3137,7 +3176,7 @@ void MainWindow::onPathSettingsFinished(int res)
void MainWindow::onUpdateAudioSettings()
{
assert(emuThread->NDS != nullptr);
- emuThread->NDS->SPU.SetInterpolation(Config::AudioInterp);
+ emuThread->NDS->SPU.SetInterpolation(static_cast<AudioInterpolation>(Config::AudioInterp));
if (Config::AudioBitDepth == 0)
emuThread->NDS->SPU.SetDegrade10Bit(emuThread->NDS->ConsoleType == 0);