Skip to content

Commit 8d67685

Browse files
committed
Add setting for toggling fastmem
1 parent c0794dd commit 8d67685

5 files changed

Lines changed: 13 additions & 3 deletions

File tree

include/config.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
#include <filesystem>
33
#include <string>
44

5-
#include "screen_layout.hpp"
65
#include "audio/dsp_core.hpp"
76
#include "frontend_settings.hpp"
87
#include "renderer.hpp"
8+
#include "screen_layout.hpp"
99
#include "services/region_codes.hpp"
1010

1111
struct AudioDeviceConfig {
@@ -58,11 +58,13 @@ struct EmulatorConfig {
5858
static constexpr RendererType rendererDefault = RendererType::OpenGL;
5959
#endif
6060

61+
static constexpr bool enableFastmemDefault = true;
6162
static constexpr bool hashTexturesDefault = false;
6263

6364
bool shaderJitEnabled = shaderJitDefault;
6465
bool useUbershaders = ubershaderDefault;
6566
bool accelerateShaders = accelerateShadersDefault;
67+
bool fastmemEnabled = enableFastmemDefault;
6668
bool hashTextures = hashTexturesDefault;
6769

6870
ScreenLayout::Layout screenLayout = ScreenLayout::Layout::Default;

include/emulator.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ enum class ROMType {
3939
};
4040

4141
class Emulator {
42+
// Config should be initialized before anything else
4243
EmulatorConfig config;
4344

4445
Memory memory;

src/config.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ void EmulatorConfig::load() {
4848

4949
printAppVersion = toml::find_or<toml::boolean>(general, "PrintAppVersion", true);
5050
circlePadProEnabled = toml::find_or<toml::boolean>(general, "EnableCirclePadPro", true);
51+
fastmemEnabled = toml::find_or<toml::boolean>(general, "EnableFastmem", enableFastmemDefault);
5152
systemLanguage = languageCodeFromString(toml::find_or<std::string>(general, "SystemLanguage", "en"));
5253
}
5354
}
@@ -180,6 +181,7 @@ void EmulatorConfig::save() {
180181
data["General"]["PrintAppVersion"] = printAppVersion;
181182
data["General"]["SystemLanguage"] = languageCodeToString(systemLanguage);
182183
data["General"]["EnableCirclePadPro"] = circlePadProEnabled;
184+
data["General"]["EnableFastmem"] = fastmemEnabled;
183185

184186
data["Window"]["AppVersionOnWindow"] = windowSettings.showAppVersion;
185187
data["Window"]["RememberWindowPosition"] = windowSettings.rememberPosition;

src/core/memory.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,16 @@ CMRC_DECLARE(ConsoleFonts);
1616
using namespace KernelMemoryTypes;
1717

1818
Memory::Memory(KFcram& fcramManager, const EmulatorConfig& config) : fcramManager(fcramManager), config(config) {
19-
arena = new Common::HostMemory(FASTMEM_BACKING_SIZE, FASTMEM_VIRTUAL_SIZE, false);
19+
const bool fastmemEnabled = config.fastmemEnabled;
20+
arena = new Common::HostMemory(FASTMEM_BACKING_SIZE, FASTMEM_VIRTUAL_SIZE, fastmemEnabled);
2021

2122
readTable.resize(totalPageCount, 0);
2223
writeTable.resize(totalPageCount, 0);
2324
paddrTable.resize(totalPageCount, 0);
2425

2526
fcram = arena->BackingBasePointer() + FASTMEM_FCRAM_OFFSET;
2627
// arenaDSPRam = arena->BackingBasePointer() + FASTMEM_DSP_RAM_OFFSET;
27-
useFastmem = arena->VirtualBasePointer() != nullptr;
28+
useFastmem = fastmemEnabled && arena->VirtualBasePointer() != nullptr;
2829
}
2930

3031
void Memory::reset() {

src/panda_qt/config_window.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,10 @@ ConfigWindow::ConfigWindow(ConfigCallback configCallback, MainWindowCallback win
172172
connectCheckbox(circlePadProEnabled, config.circlePadProEnabled);
173173
genLayout->addRow(circlePadProEnabled);
174174

175+
QCheckBox* fastmemEnabled = new QCheckBox(tr("Enable fastmem"));
176+
connectCheckbox(fastmemEnabled, config.fastmemEnabled);
177+
genLayout->addRow(fastmemEnabled);
178+
175179
QCheckBox* discordRpcEnabled = new QCheckBox(tr("Enable Discord RPC"));
176180
connectCheckbox(discordRpcEnabled, config.discordRpcEnabled);
177181
genLayout->addRow(discordRpcEnabled);

0 commit comments

Comments
 (0)