diff --git a/rpcs3/Emu/ARMv7/ARMv7Thread.cpp b/rpcs3/Emu/ARMv7/ARMv7Thread.cpp index c104182a52..d25063e688 100644 --- a/rpcs3/Emu/ARMv7/ARMv7Thread.cpp +++ b/rpcs3/Emu/ARMv7/ARMv7Thread.cpp @@ -3,6 +3,7 @@ #include "Utilities/Log.h" #include "Emu/Memory/Memory.h" #include "Emu/System.h" +#include "Emu/state.h" #include "Emu/IdManager.h" #include "Emu/ARMv7/PSVFuncList.h" @@ -179,14 +180,14 @@ void ARMv7Thread::do_run() { m_dec.reset(); - switch(Ini.CPUDecoderMode.GetValue()) + switch((int)rpcs3::state.config.core.ppu_decoder.value()) { case 0: case 1: m_dec.reset(new ARMv7Decoder(*this)); break; default: - LOG_ERROR(ARMv7, "Invalid CPU decoder mode: %d", Ini.CPUDecoderMode.GetValue()); + LOG_ERROR(ARMv7, "Invalid CPU decoder mode: %d", (int)rpcs3::state.config.core.ppu_decoder.value()); Emu.Pause(); } } diff --git a/rpcs3/Emu/Cell/PPUThread.cpp b/rpcs3/Emu/Cell/PPUThread.cpp index fa9bd6e032..b84437359f 100644 --- a/rpcs3/Emu/Cell/PPUThread.cpp +++ b/rpcs3/Emu/Cell/PPUThread.cpp @@ -3,6 +3,7 @@ #include "Utilities/Log.h" #include "Emu/Memory/Memory.h" #include "Emu/System.h" +#include "Emu/state.h" #include "Emu/IdManager.h" #include "Emu/Cell/PPUThread.h" #include "Emu/Cell/PPUDecoder.h" @@ -143,20 +144,20 @@ void PPUThread::do_run() { m_dec.reset(); - switch (auto mode = Ini.CPUDecoderMode.GetValue()) + switch (auto mode = rpcs3::state.config.core.ppu_decoder.value()) { - case 0: // original interpreter + case ppu_decoder_type::interpreter: // original interpreter { m_dec.reset(new PPUDecoder(new PPUInterpreter(*this))); break; } - case 1: // alternative interpreter + case ppu_decoder_type::interpreter2: // alternative interpreter { break; } - case 2: + case ppu_decoder_type::recompiler_llvm: { #ifdef PPU_LLVM_RECOMPILER m_dec.reset(new ppu_recompiler_llvm::CPUHybridDecoderRecompiler(*this)); diff --git a/rpcs3/Emu/Cell/SPUThread.cpp b/rpcs3/Emu/Cell/SPUThread.cpp index 39799ea018..d57782a88b 100644 --- a/rpcs3/Emu/Cell/SPUThread.cpp +++ b/rpcs3/Emu/Cell/SPUThread.cpp @@ -3,6 +3,7 @@ #include "Utilities/Log.h" #include "Emu/Memory/Memory.h" #include "Emu/System.h" +#include "Emu/state.h" #include "Emu/IdManager.h" #include "Emu/Cell/PPUThread.h" @@ -111,7 +112,7 @@ void SPUThread::task() if (!custom_task && !m_dec) { // Select opcode table (TODO) - const auto& table = Ini.SPUDecoderMode.GetValue() == 0 ? spu_interpreter::precise::g_spu_opcode_table : spu_interpreter::fast::g_spu_opcode_table; + const auto& table = rpcs3::state.config.core.spu_decoder.value() == spu_decoder_type::interpreter_precise ? spu_interpreter::precise::g_spu_opcode_table : spu_interpreter::fast::g_spu_opcode_table; // LS base address const auto base = vm::_ptr(offset); @@ -208,15 +209,15 @@ void SPUThread::do_run() { m_dec.reset(); - switch (auto mode = Ini.SPUDecoderMode.GetValue()) + switch (auto mode = rpcs3::state.config.core.spu_decoder.value()) { - case 0: // Interpreter 1 (Precise) - case 1: // Interpreter 2 (Fast) + case spu_decoder_type::interpreter_precise: // Interpreter 1 (Precise) + case spu_decoder_type::interpreter_fast: // Interpreter 2 (Fast) { break; } - case 2: + case spu_decoder_type::recompiler_asmjit: { m_dec.reset(new SPURecompilerDecoder(*this)); break; @@ -224,7 +225,7 @@ void SPUThread::do_run() default: { - LOG_ERROR(SPU, "Invalid SPU decoder mode: %d", mode); + LOG_ERROR(SPU, "Invalid SPU decoder mode: %d", (u8)mode); Emu.Pause(); } } diff --git a/rpcs3/Emu/System.cpp b/rpcs3/Emu/System.cpp index 36aceeac50..a372e1c2f7 100644 --- a/rpcs3/Emu/System.cpp +++ b/rpcs3/Emu/System.cpp @@ -191,9 +191,6 @@ void Emulator::Load() ResetInfo(); GetVFS().Init(elf_dir); - // TODO: use state configuration instead of global config - rpcs3::state.config = rpcs3::config; - LOG_NOTICE(LOADER, "Loading '%s'...", m_path.c_str()); // /dev_bdvd/ mounting @@ -229,8 +226,8 @@ void Emulator::Load() LOG_NOTICE(LOADER, ""); LOG_NOTICE(LOADER, "Settings:"); - LOG_NOTICE(LOADER, "CPU: %s", Ini.CPUIdToString(Ini.CPUDecoderMode.GetValue())); - LOG_NOTICE(LOADER, "SPU: %s", Ini.SPUIdToString(Ini.SPUDecoderMode.GetValue())); + //LOG_NOTICE(LOADER, "CPU: %s", Ini.CPUIdToString(Ini.CPUDecoderMode.GetValue())); + //LOG_NOTICE(LOADER, "SPU: %s", Ini.SPUIdToString(Ini.SPUDecoderMode.GetValue())); LOG_NOTICE(LOADER, "Renderer: %s", Ini.RendererIdToString(Ini.GSRenderMode.GetValue())); if (Ini.GSRenderMode.GetValue() == 2) @@ -247,10 +244,6 @@ void Emulator::Load() LOG_NOTICE(LOADER, "Log Everything: %s", Ini.HLELogging.GetValue() ? "Yes" : "No"); LOG_NOTICE(LOADER, "RSX Logging: %s", Ini.RSXLogging.GetValue() ? "Yes" : "No"); - LOG_NOTICE(LOADER, ""); - - LOG_NOTICE(LOADER, rpcs3::config.to_string().c_str()); - LOG_NOTICE(LOADER, ""); f.Open("/app_home/../PARAM.SFO"); const PSFLoader psf(f); @@ -262,7 +255,9 @@ void Emulator::Load() title.length() ? SetTitle(title) : SetTitle(m_path); SetTitleID(title_id); - // load custom config as global + rpcs3::state.config = rpcs3::config; + + // load custom config if (!Ini.UseDefaultIni.GetValue()) { std::string& name = title_id; @@ -270,12 +265,15 @@ void Emulator::Load() { name = name.substr(0, 4) + "-" + name.substr(4, 5); CreateConfig(name); - rpcs3::config.path("data/" + name + "/" + name + ".ini"); - rpcs3::config.load(); + rpcs3::config_t custom_config { "data/" + name + "/" + name + ".ini" }; + custom_config.load(); + rpcs3::state.config = custom_config; } } - LOG_NOTICE(LOADER, "Used configuration: '%s'", rpcs3::config.path().c_str()); + LOG_NOTICE(LOADER, "Used configuration: '%s'", rpcs3::state.config.path().c_str()); + LOG_NOTICE(LOADER, ""); + LOG_NOTICE(LOADER, rpcs3::state.config.to_string().c_str()); if (m_elf_path.empty()) { @@ -478,8 +476,7 @@ void Emulator::Stop() RSXIOMem.Clear(); vm::close(); - rpcs3::config.path("rpcs3.new.ini"); // fallback to default .ini - rpcs3::config.load(); + rpcs3::state.config = rpcs3::config; // fallback to default .ini SendDbgCommand(DID_STOPPED_EMU); } diff --git a/rpcs3/Gui/GameViewer.cpp b/rpcs3/Gui/GameViewer.cpp index d08209af8a..1d069bd3b0 100644 --- a/rpcs3/Gui/GameViewer.cpp +++ b/rpcs3/Gui/GameViewer.cpp @@ -7,6 +7,7 @@ #include "Emu/FS/VFS.h" #include "Emu/FS/vfsDir.h" #include "Emu/FS/vfsFile.h" +#include "Emu/state.h" #include "GameViewer.h" #include "Loader/PSF.h" #include "SettingsDialog.h" @@ -286,12 +287,10 @@ void GameViewer::ConfigureGame(wxCommandEvent& WXUNUSED(event)) if (i < 0) return; Emu.CreateConfig(m_game_data[i].serial); - rpcs3::config.path("data/" + m_game_data[i].serial + "/" + m_game_data[i].serial + ".ini"); - LOG_NOTICE(LOADER, "Configure: '%s'", rpcs3::config.path().c_str()); - rpcs3::config.load(); - SettingsDialog(this); - rpcs3::config.path("rpcs3.new.ini"); - rpcs3::config.load(); + rpcs3::config_t custom_config { "data/" + m_game_data[i].serial + "/" + m_game_data[i].serial + ".ini" }; + custom_config.load(); + LOG_NOTICE(LOADER, "Configure: '%s'", custom_config.path().c_str()); + SettingsDialog(this, &custom_config); } void GameViewer::RemoveGame(wxCommandEvent& event) diff --git a/rpcs3/Gui/SettingsDialog.cpp b/rpcs3/Gui/SettingsDialog.cpp index f41f0036ac..9d34537edc 100644 --- a/rpcs3/Gui/SettingsDialog.cpp +++ b/rpcs3/Gui/SettingsDialog.cpp @@ -2,6 +2,7 @@ #include "Ini.h" #include "Emu/System.h" +#include "Emu/state.h" #include "Emu/SysCalls/Modules/cellVideoOut.h" #include "SettingsDialog.h" #include "Utilities/Log.h" @@ -89,6 +90,7 @@ SettingsDialog::SettingsDialog(wxWindow *parent, rpcs3::config_t* cfg) : wxDialog(parent, wxID_ANY, "Settings", wxDefaultPosition) { const bool was_running = Emu.Pause(); + if (was_running || Emu.IsReady()) cfg = &rpcs3::state.config; static const u32 width = 458; static const u32 height = 400; @@ -348,11 +350,11 @@ SettingsDialog::SettingsDialog(wxWindow *parent, rpcs3::config_t* cfg) chbox_emulationdir_enable->SetValue(Ini.SysEmulationDirPathEnable.GetValue()); txt_emulationdir_path->SetValue(Ini.SysEmulationDirPath.GetValue()); - rbox_ppu_decoder->SetSelection(Ini.CPUDecoderMode.GetValue() ? Ini.CPUDecoderMode.GetValue() : 0); + rbox_ppu_decoder->SetSelection((int)cfg->core.ppu_decoder.value()); txt_dbg_range_min->SetValue(std::to_string(Ini.LLVMMinId.GetValue())); txt_dbg_range_max->SetValue(std::to_string(Ini.LLVMMaxId.GetValue())); txt_llvm_threshold->SetValue(std::to_string(Ini.LLVMThreshold.GetValue())); - rbox_spu_decoder->SetSelection(Ini.SPUDecoderMode.GetValue() ? Ini.SPUDecoderMode.GetValue() : 0); + rbox_spu_decoder->SetSelection((int)cfg->core.spu_decoder.value()); cbox_gs_render->SetSelection(Ini.GSRenderMode.GetValue()); cbox_gs_d3d_adaptater->SetSelection(Ini.GSD3DAdaptater.GetValue()); cbox_gs_resolution->SetSelection(ResolutionIdToNum(Ini.GSResolution.GetValue()) - 1); @@ -487,7 +489,7 @@ SettingsDialog::SettingsDialog(wxWindow *parent, rpcs3::config_t* cfg) if (ShowModal() == wxID_OK) { - Ini.CPUDecoderMode.SetValue(rbox_ppu_decoder->GetSelection()); + cfg->core.ppu_decoder = (ppu_decoder_type)rbox_ppu_decoder->GetSelection(); long minllvmid, maxllvmid; txt_dbg_range_min->GetValue().ToLong(&minllvmid); txt_dbg_range_max->GetValue().ToLong(&maxllvmid); @@ -497,7 +499,7 @@ SettingsDialog::SettingsDialog(wxWindow *parent, rpcs3::config_t* cfg) long llvmthreshold; txt_llvm_threshold->GetValue().ToLong(&llvmthreshold); Ini.LLVMThreshold.SetValue((u32)llvmthreshold); - Ini.SPUDecoderMode.SetValue(rbox_spu_decoder->GetSelection()); + cfg->core.spu_decoder = (spu_decoder_type)rbox_spu_decoder->GetSelection(); Ini.HookStFunc.SetValue(chbox_core_hook_stfunc->GetValue()); Ini.LoadLibLv2.SetValue(chbox_core_load_liblv2->GetValue()); Ini.GSRenderMode.SetValue(cbox_gs_render->GetSelection()); diff --git a/rpcs3/config.cpp b/rpcs3/config.cpp index cd38ad0e60..3544217485 100644 --- a/rpcs3/config.cpp +++ b/rpcs3/config.cpp @@ -16,6 +16,7 @@ namespace rpcs3 config_t& config_t::operator =(const config_t& rhs) { assign(rhs); + path(rhs.path()); return *this; }