Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #10328 from AdmiralCurtiss/config-port-interface
Config: Port remaining Interface settings to new config system.
  • Loading branch information
leoetlino committed Jan 1, 2022
2 parents c216057 + b3a3ecd commit c6225e4
Show file tree
Hide file tree
Showing 30 changed files with 148 additions and 172 deletions.
14 changes: 14 additions & 0 deletions Source/Core/Core/Config/MainSettings.cpp
Expand Up @@ -8,6 +8,7 @@
#include <fmt/format.h>

#include "AudioCommon/AudioCommon.h"
#include "Common/CommonPaths.h"
#include "Common/Config/Config.h"
#include "Common/StringUtil.h"
#include "Common/Version.h"
Expand Down Expand Up @@ -198,6 +199,19 @@ const Info<bool> MAIN_USE_PANIC_HANDLERS{{System::Main, "Interface", "UsePanicHa
const Info<bool> MAIN_ABORT_ON_PANIC_ALERT{{System::Main, "Interface", "AbortOnPanicAlert"}, false};
const Info<bool> MAIN_OSD_MESSAGES{{System::Main, "Interface", "OnScreenDisplayMessages"}, true};
const Info<bool> MAIN_SKIP_NKIT_WARNING{{System::Main, "Interface", "SkipNKitWarning"}, false};
const Info<bool> MAIN_CONFIRM_ON_STOP{{System::Main, "Interface", "ConfirmStop"}, true};
const Info<ShowCursor> MAIN_SHOW_CURSOR{{System::Main, "Interface", "CursorVisibility"},
ShowCursor::OnMovement};
const Info<bool> MAIN_LOCK_CURSOR{{System::Main, "Interface", "LockCursor"}, false};
const Info<std::string> MAIN_INTERFACE_LANGUAGE{{System::Main, "Interface", "LanguageCode"}, ""};
const Info<bool> MAIN_EXTENDED_FPS_INFO{{System::Main, "Interface", "ExtendedFPSInfo"}, false};
const Info<bool> MAIN_SHOW_ACTIVE_TITLE{{System::Main, "Interface", "ShowActiveTitle"}, true};
const Info<bool> MAIN_USE_BUILT_IN_TITLE_DATABASE{
{System::Main, "Interface", "UseBuiltinTitleDatabase"}, true};
const Info<std::string> MAIN_THEME_NAME{{System::Main, "Interface", "ThemeName"},
DEFAULT_THEME_DIR};
const Info<bool> MAIN_PAUSE_ON_FOCUS_LOST{{System::Main, "Interface", "PauseOnFocusLost"}, false};
const Info<bool> MAIN_ENABLE_DEBUGGING{{System::Main, "Interface", "DebugModeEnabled"}, false};

// Main.Analytics

Expand Down
18 changes: 18 additions & 0 deletions Source/Core/Core/Config/MainSettings.h
Expand Up @@ -167,6 +167,24 @@ extern const Info<bool> MAIN_USE_PANIC_HANDLERS;
extern const Info<bool> MAIN_ABORT_ON_PANIC_ALERT;
extern const Info<bool> MAIN_OSD_MESSAGES;
extern const Info<bool> MAIN_SKIP_NKIT_WARNING;
extern const Info<bool> MAIN_CONFIRM_ON_STOP;

enum class ShowCursor
{
Never,
Constantly,
OnMovement,
};
extern const Info<ShowCursor> MAIN_SHOW_CURSOR;

extern const Info<bool> MAIN_LOCK_CURSOR;
extern const Info<std::string> MAIN_INTERFACE_LANGUAGE;
extern const Info<bool> MAIN_EXTENDED_FPS_INFO;
extern const Info<bool> MAIN_SHOW_ACTIVE_TITLE;
extern const Info<bool> MAIN_USE_BUILT_IN_TITLE_DATABASE;
extern const Info<std::string> MAIN_THEME_NAME;
extern const Info<bool> MAIN_PAUSE_ON_FOCUS_LOST;
extern const Info<bool> MAIN_ENABLE_DEBUGGING;

// Main.Analytics

Expand Down
9 changes: 1 addition & 8 deletions Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp
Expand Up @@ -28,7 +28,7 @@ bool IsSettingSaveable(const Config::Location& config_location)
for (const std::string_view section :
{"NetPlay", "General", "GBA", "Display", "Network", "Analytics", "AndroidOverlayButtons",
"DSP", "GameList", "FifoPlayer", "AutoUpdate", "Movie", "Input", "Debug",
"BluetoothPassthrough", "USBPassthrough"})
"BluetoothPassthrough", "USBPassthrough", "Interface"})
{
if (config_location.section == section)
return true;
Expand Down Expand Up @@ -73,13 +73,6 @@ bool IsSettingSaveable(const Config::Location& config_location)
&Config::MAIN_REAL_WII_REMOTE_REPEAT_REPORTS.GetLocation(),
&Config::MAIN_DSP_HLE.GetLocation(),

// Main.Interface

&Config::MAIN_USE_PANIC_HANDLERS.GetLocation(),
&Config::MAIN_ABORT_ON_PANIC_ALERT.GetLocation(),
&Config::MAIN_OSD_MESSAGES.GetLocation(),
&Config::MAIN_SKIP_NKIT_WARNING.GetLocation(),

// UI.General

&Config::MAIN_USE_DISCORD_PRESENCE.GetLocation(),
Expand Down
35 changes: 0 additions & 35 deletions Source/Core/Core/ConfigManager.cpp
Expand Up @@ -89,7 +89,6 @@ void SConfig::SaveSettings()
ini.Load(File::GetUserPath(F_DOLPHINCONFIG_IDX)); // load first to not kill unknown stuff

SaveGeneralSettings(ini);
SaveInterfaceSettings(ini);
SaveCoreSettings(ini);

ini.Save(File::GetUserPath(F_DOLPHINCONFIG_IDX));
Expand Down Expand Up @@ -129,22 +128,6 @@ void SConfig::SaveGeneralSettings(IniFile& ini)
general->Set("GDBPort", iGDBPort);
}

void SConfig::SaveInterfaceSettings(IniFile& ini)
{
IniFile::Section* interface = ini.GetOrCreateSection("Interface");

interface->Set("ConfirmStop", bConfirmStop);
interface->Set("CursorVisibility", m_show_cursor);
interface->Set("LockCursor", bLockCursor);
interface->Set("LanguageCode", m_InterfaceLanguage);
interface->Set("ExtendedFPSInfo", m_InterfaceExtendedFPSInfo);
interface->Set("ShowActiveTitle", m_show_active_title);
interface->Set("UseBuiltinTitleDatabase", m_use_builtin_title_database);
interface->Set("ThemeName", theme_name);
interface->Set("PauseOnFocusLost", m_PauseOnFocusLost);
interface->Set("DebugModeEnabled", bEnableDebugging);
}

void SConfig::SaveCoreSettings(IniFile& ini)
{
IniFile::Section* core = ini.GetOrCreateSection("Core");
Expand Down Expand Up @@ -203,7 +186,6 @@ void SConfig::LoadSettings()
ini.Load(File::GetUserPath(F_DOLPHINCONFIG_IDX));

LoadGeneralSettings(ini);
LoadInterfaceSettings(ini);
LoadCoreSettings(ini);
}

Expand Down Expand Up @@ -234,22 +216,6 @@ void SConfig::LoadGeneralSettings(IniFile& ini)
general->Get("WirelessMac", &m_WirelessMac);
}

void SConfig::LoadInterfaceSettings(IniFile& ini)
{
IniFile::Section* interface = ini.GetOrCreateSection("Interface");

interface->Get("ConfirmStop", &bConfirmStop, true);
interface->Get("CursorVisibility", &m_show_cursor, ShowCursor::OnMovement);
interface->Get("LockCursor", &bLockCursor, false);
interface->Get("LanguageCode", &m_InterfaceLanguage, "");
interface->Get("ExtendedFPSInfo", &m_InterfaceExtendedFPSInfo, false);
interface->Get("ShowActiveTitle", &m_show_active_title, true);
interface->Get("UseBuiltinTitleDatabase", &m_use_builtin_title_database, true);
interface->Get("ThemeName", &theme_name, DEFAULT_THEME_DIR);
interface->Get("PauseOnFocusLost", &m_PauseOnFocusLost, false);
interface->Get("DebugModeEnabled", &bEnableDebugging, false);
}

void SConfig::LoadCoreSettings(IniFile& ini)
{
IniFile::Section* core = ini.GetOrCreateSection("Core");
Expand Down Expand Up @@ -423,7 +389,6 @@ void SConfig::OnNewTitleLoad()

void SConfig::LoadDefaults()
{
bEnableDebugging = false;
bAutomaticStart = false;
bBootToPause = false;

Expand Down
24 changes: 0 additions & 24 deletions Source/Core/Core/ConfigManager.h
Expand Up @@ -69,7 +69,6 @@ struct SConfig
std::vector<std::string> m_ISOFolder;

// Settings
bool bEnableDebugging = false;
int iGDBPort;
#ifndef _WIN32
std::string gdb_socket;
Expand Down Expand Up @@ -115,19 +114,6 @@ struct SConfig
bool bWii = false;
bool m_is_mios = false;

// Interface settings
bool bConfirmStop = false;

enum class ShowCursor
{
Never,
Constantly,
OnMovement,
} m_show_cursor;

bool bLockCursor = false;
std::string theme_name;

// Custom RTC
bool bEnableCustomRTC;
u32 m_customRTCValue;
Expand Down Expand Up @@ -192,20 +178,12 @@ struct SConfig
std::string m_bba_xlink_ip;
bool m_bba_xlink_chat_osd = true;

// interface language
std::string m_InterfaceLanguage;
float m_EmulationSpeed;
// other interface settings
bool m_InterfaceExtendedFPSInfo;
bool m_show_active_title = false;
bool m_use_builtin_title_database = true;

std::string m_WirelessMac;
bool m_ShowLag;
bool m_ShowFrameCount;

bool m_PauseOnFocusLost;

// Input settings
bool m_AdapterRumble[4];
bool m_AdapterKonga[4];
Expand All @@ -231,11 +209,9 @@ struct SConfig
~SConfig();

void SaveGeneralSettings(IniFile& ini);
void SaveInterfaceSettings(IniFile& ini);
void SaveCoreSettings(IniFile& ini);

void LoadGeneralSettings(IniFile& ini);
void LoadInterfaceSettings(IniFile& ini);
void LoadCoreSettings(IniFile& ini);

void SetRunningGameMetadata(const std::string& game_id, const std::string& gametdb_id,
Expand Down
4 changes: 2 additions & 2 deletions Source/Core/Core/Core.cpp
Expand Up @@ -954,7 +954,7 @@ void UpdateTitle(u32 ElapseTime)
else
{
SFPS = fmt::format("FPS: {:.0f} - VPS: {:.0f} - {:.0f}%", FPS, VPS, Speed);
if (SConfig::GetInstance().m_InterfaceExtendedFPSInfo)
if (Config::Get(Config::MAIN_EXTENDED_FPS_INFO))
{
// Use extended or summary information. The summary information does not print the ticks data,
// that's more of a debugging interest, it can always be optional of course if someone is
Expand All @@ -980,7 +980,7 @@ void UpdateTitle(u32 ElapseTime)
}

std::string message = fmt::format("{} | {} | {}", Common::scm_rev_str, SSettings, SFPS);
if (SConfig::GetInstance().m_show_active_title)
if (Config::Get(Config::MAIN_SHOW_ACTIVE_TITLE))
{
const std::string& title = SConfig::GetInstance().GetTitleDescription();
if (!title.empty())
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/HLE/HLE.cpp
Expand Up @@ -189,7 +189,7 @@ HookFlag GetHookFlagsByIndex(u32 index)

bool IsEnabled(HookFlag flag)
{
return flag != HLE::HookFlag::Debug || SConfig::GetInstance().bEnableDebugging ||
return flag != HLE::HookFlag::Debug || Config::Get(Config::MAIN_ENABLE_DEBUGGING) ||
PowerPC::GetMode() == PowerPC::CoreMode::Interpreter;
}

Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/HW/VideoInterface.cpp
Expand Up @@ -882,7 +882,7 @@ void Update(u64 ticks)
if (s_half_line_of_next_si_poll == s_half_line_count)
{
Core::UpdateInputGate(!Config::Get(Config::MAIN_INPUT_BACKGROUND_INPUT),
SConfig::GetInstance().bLockCursor);
Config::Get(Config::MAIN_LOCK_CURSOR));
SerialInterface::UpdateDevices();
s_half_line_of_next_si_poll += 2 * SerialInterface::GetPollXLines();
}
Expand Down
Expand Up @@ -273,8 +273,8 @@ void CachedInterpreter::Jit(u32 address)

if (!op.skip)
{
const bool breakpoint = SConfig::GetInstance().bEnableDebugging &&
PowerPC::breakpoints.IsAddressBreakPoint(op.address);
const bool breakpoint =
m_enable_debugging && PowerPC::breakpoints.IsAddressBreakPoint(op.address);
const bool check_fpu = (op.opinfo->flags & FL_USE_FPU) && !js.firstFPInstructionFound;
const bool endblock = (op.opinfo->flags & FL_ENDBLOCK) != 0;
const bool memcheck = (op.opinfo->flags & FL_LOADSTORE) && jo.memcheck;
Expand Down
4 changes: 2 additions & 2 deletions Source/Core/Core/PowerPC/Interpreter/Interpreter.cpp
Expand Up @@ -14,7 +14,7 @@
#include "Common/GekkoDisassembler.h"
#include "Common/Logging/Log.h"
#include "Common/StringUtil.h"
#include "Core/ConfigManager.h"
#include "Core/Config/MainSettings.h"
#include "Core/CoreTiming.h"
#include "Core/Debugger/Debugger_SymbolMap.h"
#include "Core/HLE/HLE.h"
Expand Down Expand Up @@ -247,7 +247,7 @@ void Interpreter::Run()
CoreTiming::Advance();

// we have to check exceptions at branches apparently (or maybe just rfi?)
if (SConfig::GetInstance().bEnableDebugging)
if (Config::Get(Config::MAIN_ENABLE_DEBUGGING))
{
#ifdef SHOW_HISTORY
s_pc_block_vec.push_back(PC);
Expand Down
15 changes: 7 additions & 8 deletions Source/Core/Core/PowerPC/Jit64/Jit.cpp
Expand Up @@ -355,8 +355,8 @@ void Jit64::Init()

// BLR optimization has the same consequences as block linking, as well as
// depending on the fault handler to be safe in the event of excessive BL.
m_enable_blr_optimization = jo.enableBlocklink && SConfig::GetInstance().bFastmem &&
!SConfig::GetInstance().bEnableDebugging;
m_enable_blr_optimization =
jo.enableBlocklink && SConfig::GetInstance().bFastmem && !m_enable_debugging;
m_cleanup_after_stackfault = false;

m_stack = nullptr;
Expand Down Expand Up @@ -603,8 +603,8 @@ void Jit64::JustWriteExit(u32 destination, bool bl, u32 after)
MOV(32, PPCSTATE(pc), Imm32(destination));

// Do not skip breakpoint check if debugging.
const u8* dispatcher = SConfig::GetInstance().bEnableDebugging ? asm_routines.dispatcher :
asm_routines.dispatcher_no_check;
const u8* dispatcher =
m_enable_debugging ? asm_routines.dispatcher : asm_routines.dispatcher_no_check;

// Perform downcount flag check, followed by the requested exit
if (bl)
Expand Down Expand Up @@ -796,7 +796,7 @@ void Jit64::Jit(u32 em_address, bool clear_cache_and_retry_on_failure)

std::size_t block_size = m_code_buffer.size();

if (SConfig::GetInstance().bEnableDebugging)
if (m_enable_debugging)
{
// We can link blocks as long as we are not single stepping and there are no breakpoints here
EnableBlockLink();
Expand Down Expand Up @@ -1007,7 +1007,7 @@ bool Jit64::DoJit(u32 em_address, JitBlock* b, u32 nextPC)
js.fastmemLoadStore = nullptr;
js.fixupExceptionHandler = false;

if (!SConfig::GetInstance().bEnableDebugging)
if (!m_enable_debugging)
js.downcountAmount += PatchEngine::GetSpeedhackCycles(js.compilerPC);

if (i == (code_block.m_num_instructions - 1))
Expand Down Expand Up @@ -1094,8 +1094,7 @@ bool Jit64::DoJit(u32 em_address, JitBlock* b, u32 nextPC)
js.firstFPInstructionFound = true;
}

if (SConfig::GetInstance().bEnableDebugging && breakpoints.IsAddressBreakPoint(op.address) &&
!CPU::IsStepping())
if (m_enable_debugging && breakpoints.IsAddressBreakPoint(op.address) && !CPU::IsStepping())
{
// Turn off block linking if there are breakpoints so that the Step Over command does not
// link this block.
Expand Down
11 changes: 6 additions & 5 deletions Source/Core/Core/PowerPC/Jit64/JitAsm.cpp
Expand Up @@ -9,7 +9,7 @@
#include "Common/JitRegister.h"
#include "Common/x64ABI.h"
#include "Common/x64Emitter.h"
#include "Core/ConfigManager.h"
#include "Core/Config/MainSettings.h"
#include "Core/CoreTiming.h"
#include "Core/HW/CPU.h"
#include "Core/HW/Memmap.h"
Expand Down Expand Up @@ -37,6 +37,8 @@ void Jit64AsmRoutineManager::Init(u8* stack_top)

void Jit64AsmRoutineManager::Generate()
{
const bool enable_debugging = Config::Get(Config::MAIN_ENABLE_DEBUGGING);

enter_code = AlignCode16();
// We need to own the beginning of RSP, so we do an extra stack adjustment
// for the shadow region before calls in this function. This call will
Expand Down Expand Up @@ -65,8 +67,7 @@ void Jit64AsmRoutineManager::Generate()
ABI_PushRegistersAndAdjustStack({}, 0);
ABI_CallFunction(CoreTiming::Advance);
ABI_PopRegistersAndAdjustStack({}, 0);
FixupBranch skipToRealDispatch =
J(SConfig::GetInstance().bEnableDebugging); // skip the sync and compare first time
FixupBranch skipToRealDispatch = J(enable_debugging); // skip the sync and compare first time
dispatcher_mispredicted_blr = GetCodePtr();
AND(32, PPCSTATE(pc), Imm32(0xFFFFFFFC));

Expand All @@ -88,7 +89,7 @@ void Jit64AsmRoutineManager::Generate()

FixupBranch dbg_exit;

if (SConfig::GetInstance().bEnableDebugging)
if (enable_debugging)
{
MOV(64, R(RSCRATCH), ImmPtr(CPU::GetStatePtr()));
TEST(32, MatR(RSCRATCH), Imm32(static_cast<u32>(CPU::State::Stepping)));
Expand Down Expand Up @@ -205,7 +206,7 @@ void Jit64AsmRoutineManager::Generate()
J_CC(CC_Z, outerLoop);

// Landing pad for drec space
if (SConfig::GetInstance().bEnableDebugging)
if (enable_debugging)
SetJumpTarget(dbg_exit);
ResetStack(*this);
if (m_stack_top)
Expand Down
5 changes: 2 additions & 3 deletions Source/Core/Core/PowerPC/Jit64Common/BlockCache.cpp
Expand Up @@ -14,9 +14,8 @@ JitBlockCache::JitBlockCache(JitBase& jit) : JitBaseBlockCache{jit}
void JitBlockCache::WriteLinkBlock(const JitBlock::LinkData& source, const JitBlock* dest)
{
// Do not skip breakpoint check if debugging.
const u8* dispatcher = SConfig::GetInstance().bEnableDebugging ?
m_jit.GetAsmRoutines()->dispatcher :
m_jit.GetAsmRoutines()->dispatcher_no_check;
const u8* dispatcher = m_jit.IsDebuggingEnabled() ? m_jit.GetAsmRoutines()->dispatcher :
m_jit.GetAsmRoutines()->dispatcher_no_check;

u8* location = source.exitPtrs;
const u8* address = dest ? dest->checkedEntry : dispatcher;
Expand Down

0 comments on commit c6225e4

Please sign in to comment.