From 8d67685b934acca4b7b8d0245418c9aab3b5aac9 Mon Sep 17 00:00:00 2001 From: wheremyfoodat <44909372+wheremyfoodat@users.noreply.github.com> Date: Sun, 3 Aug 2025 18:37:06 +0300 Subject: [PATCH] Add setting for toggling fastmem --- include/config.hpp | 4 +++- include/emulator.hpp | 1 + src/config.cpp | 2 ++ src/core/memory.cpp | 5 +++-- src/panda_qt/config_window.cpp | 4 ++++ 5 files changed, 13 insertions(+), 3 deletions(-) diff --git a/include/config.hpp b/include/config.hpp index 7030a8e3..4aa4cce1 100644 --- a/include/config.hpp +++ b/include/config.hpp @@ -2,10 +2,10 @@ #include #include -#include "screen_layout.hpp" #include "audio/dsp_core.hpp" #include "frontend_settings.hpp" #include "renderer.hpp" +#include "screen_layout.hpp" #include "services/region_codes.hpp" struct AudioDeviceConfig { @@ -58,11 +58,13 @@ struct EmulatorConfig { static constexpr RendererType rendererDefault = RendererType::OpenGL; #endif + static constexpr bool enableFastmemDefault = true; static constexpr bool hashTexturesDefault = false; bool shaderJitEnabled = shaderJitDefault; bool useUbershaders = ubershaderDefault; bool accelerateShaders = accelerateShadersDefault; + bool fastmemEnabled = enableFastmemDefault; bool hashTextures = hashTexturesDefault; ScreenLayout::Layout screenLayout = ScreenLayout::Layout::Default; diff --git a/include/emulator.hpp b/include/emulator.hpp index f7d947f6..cd39f1c4 100644 --- a/include/emulator.hpp +++ b/include/emulator.hpp @@ -39,6 +39,7 @@ enum class ROMType { }; class Emulator { + // Config should be initialized before anything else EmulatorConfig config; Memory memory; diff --git a/src/config.cpp b/src/config.cpp index f2cddaba..4d489c95 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -48,6 +48,7 @@ void EmulatorConfig::load() { printAppVersion = toml::find_or(general, "PrintAppVersion", true); circlePadProEnabled = toml::find_or(general, "EnableCirclePadPro", true); + fastmemEnabled = toml::find_or(general, "EnableFastmem", enableFastmemDefault); systemLanguage = languageCodeFromString(toml::find_or(general, "SystemLanguage", "en")); } } @@ -180,6 +181,7 @@ void EmulatorConfig::save() { data["General"]["PrintAppVersion"] = printAppVersion; data["General"]["SystemLanguage"] = languageCodeToString(systemLanguage); data["General"]["EnableCirclePadPro"] = circlePadProEnabled; + data["General"]["EnableFastmem"] = fastmemEnabled; data["Window"]["AppVersionOnWindow"] = windowSettings.showAppVersion; data["Window"]["RememberWindowPosition"] = windowSettings.rememberPosition; diff --git a/src/core/memory.cpp b/src/core/memory.cpp index 0a6df093..6b6e5030 100644 --- a/src/core/memory.cpp +++ b/src/core/memory.cpp @@ -16,7 +16,8 @@ CMRC_DECLARE(ConsoleFonts); using namespace KernelMemoryTypes; Memory::Memory(KFcram& fcramManager, const EmulatorConfig& config) : fcramManager(fcramManager), config(config) { - arena = new Common::HostMemory(FASTMEM_BACKING_SIZE, FASTMEM_VIRTUAL_SIZE, false); + const bool fastmemEnabled = config.fastmemEnabled; + arena = new Common::HostMemory(FASTMEM_BACKING_SIZE, FASTMEM_VIRTUAL_SIZE, fastmemEnabled); readTable.resize(totalPageCount, 0); writeTable.resize(totalPageCount, 0); @@ -24,7 +25,7 @@ Memory::Memory(KFcram& fcramManager, const EmulatorConfig& config) : fcramManage fcram = arena->BackingBasePointer() + FASTMEM_FCRAM_OFFSET; // arenaDSPRam = arena->BackingBasePointer() + FASTMEM_DSP_RAM_OFFSET; - useFastmem = arena->VirtualBasePointer() != nullptr; + useFastmem = fastmemEnabled && arena->VirtualBasePointer() != nullptr; } void Memory::reset() { diff --git a/src/panda_qt/config_window.cpp b/src/panda_qt/config_window.cpp index 14b33156..30c75ff8 100644 --- a/src/panda_qt/config_window.cpp +++ b/src/panda_qt/config_window.cpp @@ -172,6 +172,10 @@ ConfigWindow::ConfigWindow(ConfigCallback configCallback, MainWindowCallback win connectCheckbox(circlePadProEnabled, config.circlePadProEnabled); genLayout->addRow(circlePadProEnabled); + QCheckBox* fastmemEnabled = new QCheckBox(tr("Enable fastmem")); + connectCheckbox(fastmemEnabled, config.fastmemEnabled); + genLayout->addRow(fastmemEnabled); + QCheckBox* discordRpcEnabled = new QCheckBox(tr("Enable Discord RPC")); connectCheckbox(discordRpcEnabled, config.discordRpcEnabled); genLayout->addRow(discordRpcEnabled);