summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/core.cpp64
-rw-r--r--src/core/core.h57
-rw-r--r--src/yuzu/bootmanager.cpp6
-rw-r--r--src/yuzu/bootmanager.h8
-rw-r--r--src/yuzu/main.cpp175
-rw-r--r--src/yuzu/main.h13
-rw-r--r--src/yuzu_cmd/yuzu.cpp21
7 files changed, 164 insertions, 180 deletions
diff --git a/src/core/core.cpp b/src/core/core.cpp
index bb268a319..3532839df 100644
--- a/src/core/core.cpp
+++ b/src/core/core.cpp
@@ -139,8 +139,8 @@ struct System::Impl {
139 : kernel{system}, fs_controller{system}, memory{system}, 139 : kernel{system}, fs_controller{system}, memory{system},
140 cpu_manager{system}, reporter{system}, applet_manager{system}, time_manager{system} {} 140 cpu_manager{system}, reporter{system}, applet_manager{system}, time_manager{system} {}
141 141
142 ResultStatus Run() { 142 SystemResultStatus Run() {
143 status = ResultStatus::Success; 143 status = SystemResultStatus::Success;
144 144
145 kernel.Suspend(false); 145 kernel.Suspend(false);
146 core_timing.SyncPause(false); 146 core_timing.SyncPause(false);
@@ -149,8 +149,8 @@ struct System::Impl {
149 return status; 149 return status;
150 } 150 }
151 151
152 ResultStatus Pause() { 152 SystemResultStatus Pause() {
153 status = ResultStatus::Success; 153 status = SystemResultStatus::Success;
154 154
155 core_timing.SyncPause(true); 155 core_timing.SyncPause(true);
156 kernel.Suspend(true); 156 kernel.Suspend(true);
@@ -159,7 +159,7 @@ struct System::Impl {
159 return status; 159 return status;
160 } 160 }
161 161
162 ResultStatus Init(System& system, Frontend::EmuWindow& emu_window) { 162 SystemResultStatus Init(System& system, Frontend::EmuWindow& emu_window) {
163 LOG_DEBUG(Core, "initialized OK"); 163 LOG_DEBUG(Core, "initialized OK");
164 164
165 device_memory = std::make_unique<Core::DeviceMemory>(); 165 device_memory = std::make_unique<Core::DeviceMemory>();
@@ -197,7 +197,7 @@ struct System::Impl {
197 197
198 gpu_core = VideoCore::CreateGPU(emu_window, system); 198 gpu_core = VideoCore::CreateGPU(emu_window, system);
199 if (!gpu_core) { 199 if (!gpu_core) {
200 return ResultStatus::ErrorVideoCore; 200 return SystemResultStatus::ErrorVideoCore;
201 } 201 }
202 202
203 service_manager = std::make_shared<Service::SM::ServiceManager>(kernel); 203 service_manager = std::make_shared<Service::SM::ServiceManager>(kernel);
@@ -217,21 +217,22 @@ struct System::Impl {
217 217
218 LOG_DEBUG(Core, "Initialized OK"); 218 LOG_DEBUG(Core, "Initialized OK");
219 219
220 return ResultStatus::Success; 220 return SystemResultStatus::Success;
221 } 221 }
222 222
223 ResultStatus Load(System& system, Frontend::EmuWindow& emu_window, const std::string& filepath, 223 SystemResultStatus Load(System& system, Frontend::EmuWindow& emu_window,
224 u64 program_id, std::size_t program_index) { 224 const std::string& filepath, u64 program_id,
225 std::size_t program_index) {
225 app_loader = Loader::GetLoader(system, GetGameFileFromPath(virtual_filesystem, filepath), 226 app_loader = Loader::GetLoader(system, GetGameFileFromPath(virtual_filesystem, filepath),
226 program_id, program_index); 227 program_id, program_index);
227 228
228 if (!app_loader) { 229 if (!app_loader) {
229 LOG_CRITICAL(Core, "Failed to obtain loader for {}!", filepath); 230 LOG_CRITICAL(Core, "Failed to obtain loader for {}!", filepath);
230 return ResultStatus::ErrorGetLoader; 231 return SystemResultStatus::ErrorGetLoader;
231 } 232 }
232 233
233 ResultStatus init_result{Init(system, emu_window)}; 234 SystemResultStatus init_result{Init(system, emu_window)};
234 if (init_result != ResultStatus::Success) { 235 if (init_result != SystemResultStatus::Success) {
235 LOG_CRITICAL(Core, "Failed to initialize system (Error {})!", 236 LOG_CRITICAL(Core, "Failed to initialize system (Error {})!",
236 static_cast<int>(init_result)); 237 static_cast<int>(init_result));
237 Shutdown(); 238 Shutdown();
@@ -249,8 +250,8 @@ struct System::Impl {
249 LOG_CRITICAL(Core, "Failed to load ROM (Error {})!", load_result); 250 LOG_CRITICAL(Core, "Failed to load ROM (Error {})!", load_result);
250 Shutdown(); 251 Shutdown();
251 252
252 return static_cast<ResultStatus>(static_cast<u32>(ResultStatus::ErrorLoader) + 253 return static_cast<SystemResultStatus>(
253 static_cast<u32>(load_result)); 254 static_cast<u32>(SystemResultStatus::ErrorLoader) + static_cast<u32>(load_result));
254 } 255 }
255 AddGlueRegistrationForProcess(*app_loader, *main_process); 256 AddGlueRegistrationForProcess(*app_loader, *main_process);
256 kernel.MakeCurrentProcess(main_process.get()); 257 kernel.MakeCurrentProcess(main_process.get());
@@ -282,7 +283,7 @@ struct System::Impl {
282 GetAndResetPerfStats(); 283 GetAndResetPerfStats();
283 perf_stats->BeginSystemFrame(); 284 perf_stats->BeginSystemFrame();
284 285
285 status = ResultStatus::Success; 286 status = SystemResultStatus::Success;
286 return status; 287 return status;
287 } 288 }
288 289
@@ -355,7 +356,7 @@ struct System::Impl {
355 arp_manager.Register(launch.title_id, launch, std::move(nacp_data)); 356 arp_manager.Register(launch.title_id, launch, std::move(nacp_data));
356 } 357 }
357 358
358 void SetStatus(ResultStatus new_status, const char* details = nullptr) { 359 void SetStatus(SystemResultStatus new_status, const char* details = nullptr) {
359 status = new_status; 360 status = new_status;
360 if (details) { 361 if (details) {
361 status_details = details; 362 status_details = details;
@@ -411,7 +412,7 @@ struct System::Impl {
411 /// Network instance 412 /// Network instance
412 Network::NetworkInstance network_instance; 413 Network::NetworkInstance network_instance;
413 414
414 ResultStatus status = ResultStatus::Success; 415 SystemResultStatus status = SystemResultStatus::Success;
415 std::string status_details = ""; 416 std::string status_details = "";
416 417
417 std::unique_ptr<Core::PerfStats> perf_stats; 418 std::unique_ptr<Core::PerfStats> perf_stats;
@@ -428,21 +429,8 @@ struct System::Impl {
428}; 429};
429 430
430System::System() : impl{std::make_unique<Impl>(*this)} {} 431System::System() : impl{std::make_unique<Impl>(*this)} {}
431System::~System() = default;
432
433System& System::GetInstance() {
434 if (!s_instance) {
435 throw std::runtime_error("Using System instance before its initialization");
436 }
437 return *s_instance;
438}
439 432
440void System::InitializeGlobalInstance() { 433System::~System() = default;
441 if (s_instance) {
442 throw std::runtime_error("Reinitializing Global System instance.");
443 }
444 s_instance = std::unique_ptr<System>(new System);
445}
446 434
447CpuManager& System::GetCpuManager() { 435CpuManager& System::GetCpuManager() {
448 return impl->cpu_manager; 436 return impl->cpu_manager;
@@ -452,16 +440,16 @@ const CpuManager& System::GetCpuManager() const {
452 return impl->cpu_manager; 440 return impl->cpu_manager;
453} 441}
454 442
455System::ResultStatus System::Run() { 443SystemResultStatus System::Run() {
456 return impl->Run(); 444 return impl->Run();
457} 445}
458 446
459System::ResultStatus System::Pause() { 447SystemResultStatus System::Pause() {
460 return impl->Pause(); 448 return impl->Pause();
461} 449}
462 450
463System::ResultStatus System::SingleStep() { 451SystemResultStatus System::SingleStep() {
464 return ResultStatus::Success; 452 return SystemResultStatus::Success;
465} 453}
466 454
467void System::InvalidateCpuInstructionCaches() { 455void System::InvalidateCpuInstructionCaches() {
@@ -476,8 +464,8 @@ void System::Shutdown() {
476 impl->Shutdown(); 464 impl->Shutdown();
477} 465}
478 466
479System::ResultStatus System::Load(Frontend::EmuWindow& emu_window, const std::string& filepath, 467SystemResultStatus System::Load(Frontend::EmuWindow& emu_window, const std::string& filepath,
480 u64 program_id, std::size_t program_index) { 468 u64 program_id, std::size_t program_index) {
481 return impl->Load(*this, emu_window, filepath, program_id, program_index); 469 return impl->Load(*this, emu_window, filepath, program_id, program_index);
482} 470}
483 471
@@ -637,7 +625,7 @@ Loader::ResultStatus System::GetGameName(std::string& out) const {
637 return impl->GetGameName(out); 625 return impl->GetGameName(out);
638} 626}
639 627
640void System::SetStatus(ResultStatus new_status, const char* details) { 628void System::SetStatus(SystemResultStatus new_status, const char* details) {
641 impl->SetStatus(new_status, details); 629 impl->SetStatus(new_status, details);
642} 630}
643 631
diff --git a/src/core/core.h b/src/core/core.h
index a796472b2..c1234ef77 100644
--- a/src/core/core.h
+++ b/src/core/core.h
@@ -104,55 +104,49 @@ struct PerfStatsResults;
104FileSys::VirtualFile GetGameFileFromPath(const FileSys::VirtualFilesystem& vfs, 104FileSys::VirtualFile GetGameFileFromPath(const FileSys::VirtualFilesystem& vfs,
105 const std::string& path); 105 const std::string& path);
106 106
107/// Enumeration representing the return values of the System Initialize and Load process.
108enum class SystemResultStatus : u32 {
109 Success, ///< Succeeded
110 ErrorNotInitialized, ///< Error trying to use core prior to initialization
111 ErrorGetLoader, ///< Error finding the correct application loader
112 ErrorSystemFiles, ///< Error in finding system files
113 ErrorSharedFont, ///< Error in finding shared font
114 ErrorVideoCore, ///< Error in the video core
115 ErrorUnknown, ///< Any other error
116 ErrorLoader, ///< The base for loader errors (too many to repeat)
117};
118
107class System { 119class System {
108public: 120public:
109 using CurrentBuildProcessID = std::array<u8, 0x20>; 121 using CurrentBuildProcessID = std::array<u8, 0x20>;
110 122
123 explicit System();
124
125 ~System();
126
111 System(const System&) = delete; 127 System(const System&) = delete;
112 System& operator=(const System&) = delete; 128 System& operator=(const System&) = delete;
113 129
114 System(System&&) = delete; 130 System(System&&) = delete;
115 System& operator=(System&&) = delete; 131 System& operator=(System&&) = delete;
116 132
117 ~System();
118
119 /**
120 * Gets the instance of the System singleton class.
121 * @returns Reference to the instance of the System singleton class.
122 */
123 [[deprecated("Use of the global system instance is deprecated")]] static System& GetInstance();
124
125 static void InitializeGlobalInstance();
126
127 /// Enumeration representing the return values of the System Initialize and Load process.
128 enum class ResultStatus : u32 {
129 Success, ///< Succeeded
130 ErrorNotInitialized, ///< Error trying to use core prior to initialization
131 ErrorGetLoader, ///< Error finding the correct application loader
132 ErrorSystemFiles, ///< Error in finding system files
133 ErrorSharedFont, ///< Error in finding shared font
134 ErrorVideoCore, ///< Error in the video core
135 ErrorUnknown, ///< Any other error
136 ErrorLoader, ///< The base for loader errors (too many to repeat)
137 };
138
139 /** 133 /**
140 * Run the OS and Application 134 * Run the OS and Application
141 * This function will start emulation and run the relevant devices 135 * This function will start emulation and run the relevant devices
142 */ 136 */
143 [[nodiscard]] ResultStatus Run(); 137 [[nodiscard]] SystemResultStatus Run();
144 138
145 /** 139 /**
146 * Pause the OS and Application 140 * Pause the OS and Application
147 * This function will pause emulation and stop the relevant devices 141 * This function will pause emulation and stop the relevant devices
148 */ 142 */
149 [[nodiscard]] ResultStatus Pause(); 143 [[nodiscard]] SystemResultStatus Pause();
150 144
151 /** 145 /**
152 * Step the CPU one instruction 146 * Step the CPU one instruction
153 * @return Result status, indicating whether or not the operation succeeded. 147 * @return Result status, indicating whether or not the operation succeeded.
154 */ 148 */
155 [[nodiscard]] ResultStatus SingleStep(); 149 [[nodiscard]] SystemResultStatus SingleStep();
156 150
157 /** 151 /**
158 * Invalidate the CPU instruction caches 152 * Invalidate the CPU instruction caches
@@ -172,10 +166,11 @@ public:
172 * input. 166 * input.
173 * @param filepath String path to the executable application to load on the host file system. 167 * @param filepath String path to the executable application to load on the host file system.
174 * @param program_index Specifies the index within the container of the program to launch. 168 * @param program_index Specifies the index within the container of the program to launch.
175 * @returns ResultStatus code, indicating if the operation succeeded. 169 * @returns SystemResultStatus code, indicating if the operation succeeded.
176 */ 170 */
177 [[nodiscard]] ResultStatus Load(Frontend::EmuWindow& emu_window, const std::string& filepath, 171 [[nodiscard]] SystemResultStatus Load(Frontend::EmuWindow& emu_window,
178 u64 program_id = 0, std::size_t program_index = 0); 172 const std::string& filepath, u64 program_id = 0,
173 std::size_t program_index = 0);
179 174
180 /** 175 /**
181 * Indicates if the emulated system is powered on (all subsystems initialized and able to run an 176 * Indicates if the emulated system is powered on (all subsystems initialized and able to run an
@@ -301,7 +296,7 @@ public:
301 /// Gets the name of the current game 296 /// Gets the name of the current game
302 [[nodiscard]] Loader::ResultStatus GetGameName(std::string& out) const; 297 [[nodiscard]] Loader::ResultStatus GetGameName(std::string& out) const;
303 298
304 void SetStatus(ResultStatus new_status, const char* details); 299 void SetStatus(SystemResultStatus new_status, const char* details);
305 300
306 [[nodiscard]] const std::string& GetStatusDetails() const; 301 [[nodiscard]] const std::string& GetStatusDetails() const;
307 302
@@ -403,12 +398,8 @@ public:
403 void ApplySettings(); 398 void ApplySettings();
404 399
405private: 400private:
406 System();
407
408 struct Impl; 401 struct Impl;
409 std::unique_ptr<Impl> impl; 402 std::unique_ptr<Impl> impl;
410
411 inline static std::unique_ptr<System> s_instance{};
412}; 403};
413 404
414} // namespace Core 405} // namespace Core
diff --git a/src/yuzu/bootmanager.cpp b/src/yuzu/bootmanager.cpp
index c75f5e1ee..40fd47406 100644
--- a/src/yuzu/bootmanager.cpp
+++ b/src/yuzu/bootmanager.cpp
@@ -86,15 +86,15 @@ void EmuThread::run() {
86 } 86 }
87 87
88 running_guard = true; 88 running_guard = true;
89 Core::System::ResultStatus result = system.Run(); 89 Core::SystemResultStatus result = system.Run();
90 if (result != Core::System::ResultStatus::Success) { 90 if (result != Core::SystemResultStatus::Success) {
91 running_guard = false; 91 running_guard = false;
92 this->SetRunning(false); 92 this->SetRunning(false);
93 emit ErrorThrown(result, system.GetStatusDetails()); 93 emit ErrorThrown(result, system.GetStatusDetails());
94 } 94 }
95 running_wait.Wait(); 95 running_wait.Wait();
96 result = system.Pause(); 96 result = system.Pause();
97 if (result != Core::System::ResultStatus::Success) { 97 if (result != Core::SystemResultStatus::Success) {
98 running_guard = false; 98 running_guard = false;
99 this->SetRunning(false); 99 this->SetRunning(false);
100 emit ErrorThrown(result, system.GetStatusDetails()); 100 emit ErrorThrown(result, system.GetStatusDetails());
diff --git a/src/yuzu/bootmanager.h b/src/yuzu/bootmanager.h
index 8d7ab8c2e..e6a0666e9 100644
--- a/src/yuzu/bootmanager.h
+++ b/src/yuzu/bootmanager.h
@@ -16,7 +16,6 @@
16#include <QWindow> 16#include <QWindow>
17 17
18#include "common/thread.h" 18#include "common/thread.h"
19#include "core/core.h"
20#include "core/frontend/emu_window.h" 19#include "core/frontend/emu_window.h"
21 20
22class GRenderWindow; 21class GRenderWindow;
@@ -24,6 +23,11 @@ class GMainWindow;
24class QKeyEvent; 23class QKeyEvent;
25class QStringList; 24class QStringList;
26 25
26namespace Core {
27enum class SystemResultStatus : u32;
28class System;
29} // namespace Core
30
27namespace InputCommon { 31namespace InputCommon {
28class InputSubsystem; 32class InputSubsystem;
29} 33}
@@ -123,7 +127,7 @@ signals:
123 */ 127 */
124 void DebugModeLeft(); 128 void DebugModeLeft();
125 129
126 void ErrorThrown(Core::System::ResultStatus, std::string); 130 void ErrorThrown(Core::SystemResultStatus, std::string);
127 131
128 void LoadProgress(VideoCore::LoadCallbackStage stage, std::size_t value, std::size_t total); 132 void LoadProgress(VideoCore::LoadCallbackStage stage, std::size_t value, std::size_t total);
129}; 133};
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp
index 00e649fd2..3155a5c19 100644
--- a/src/yuzu/main.cpp
+++ b/src/yuzu/main.cpp
@@ -172,7 +172,7 @@ void GMainWindow::ShowTelemetryCallout() {
172 "<br/><br/>Would you like to share your usage data with us?"); 172 "<br/><br/>Would you like to share your usage data with us?");
173 if (QMessageBox::question(this, tr("Telemetry"), telemetry_message) != QMessageBox::Yes) { 173 if (QMessageBox::question(this, tr("Telemetry"), telemetry_message) != QMessageBox::Yes) {
174 Settings::values.enable_telemetry = false; 174 Settings::values.enable_telemetry = false;
175 system.ApplySettings(); 175 system->ApplySettings();
176 } 176 }
177} 177}
178 178
@@ -191,9 +191,10 @@ static void RemoveCachedContents() {
191 Common::FS::RemoveDirRecursively(offline_system_data); 191 Common::FS::RemoveDirRecursively(offline_system_data);
192} 192}
193 193
194GMainWindow::GMainWindow(Core::System& system_) 194GMainWindow::GMainWindow()
195 : input_subsystem{std::make_shared<InputCommon::InputSubsystem>()}, system{system_}, 195 : system{std::make_unique<Core::System>()},
196 config{std::make_unique<Config>(system_)}, 196 input_subsystem{std::make_shared<InputCommon::InputSubsystem>()},
197 config{std::make_unique<Config>(*system)},
197 vfs{std::make_shared<FileSys::RealVfsFilesystem>()}, 198 vfs{std::make_shared<FileSys::RealVfsFilesystem>()},
198 provider{std::make_unique<FileSys::ManualContentProvider>()} { 199 provider{std::make_unique<FileSys::ManualContentProvider>()} {
199 Common::Log::Initialize(); 200 Common::Log::Initialize();
@@ -257,10 +258,10 @@ GMainWindow::GMainWindow(Core::System& system_)
257 258
258 show(); 259 show();
259 260
260 system.SetContentProvider(std::make_unique<FileSys::ContentProviderUnion>()); 261 system->SetContentProvider(std::make_unique<FileSys::ContentProviderUnion>());
261 system.RegisterContentProvider(FileSys::ContentProviderUnionSlot::FrontendManual, 262 system->RegisterContentProvider(FileSys::ContentProviderUnionSlot::FrontendManual,
262 provider.get()); 263 provider.get());
263 system.GetFileSystemController().CreateFactories(*vfs); 264 system->GetFileSystemController().CreateFactories(*vfs);
264 265
265 // Remove cached contents generated during the previous session 266 // Remove cached contents generated during the previous session
266 RemoveCachedContents(); 267 RemoveCachedContents();
@@ -406,12 +407,12 @@ void GMainWindow::RegisterMetaTypes() {
406 qRegisterMetaType<Service::AM::Applets::WebExitReason>("Service::AM::Applets::WebExitReason"); 407 qRegisterMetaType<Service::AM::Applets::WebExitReason>("Service::AM::Applets::WebExitReason");
407 408
408 // Register loader types 409 // Register loader types
409 qRegisterMetaType<Core::System::ResultStatus>("Core::System::ResultStatus"); 410 qRegisterMetaType<Core::SystemResultStatus>("Core::SystemResultStatus");
410} 411}
411 412
412void GMainWindow::ControllerSelectorReconfigureControllers( 413void GMainWindow::ControllerSelectorReconfigureControllers(
413 const Core::Frontend::ControllerParameters& parameters) { 414 const Core::Frontend::ControllerParameters& parameters) {
414 QtControllerSelectorDialog dialog(this, parameters, input_subsystem.get(), system); 415 QtControllerSelectorDialog dialog(this, parameters, input_subsystem.get(), *system);
415 416
416 dialog.setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint | 417 dialog.setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint |
417 Qt::WindowTitleHint | Qt::WindowSystemMenuHint); 418 Qt::WindowTitleHint | Qt::WindowSystemMenuHint);
@@ -421,7 +422,7 @@ void GMainWindow::ControllerSelectorReconfigureControllers(
421 emit ControllerSelectorReconfigureFinished(); 422 emit ControllerSelectorReconfigureFinished();
422 423
423 // Don't forget to apply settings. 424 // Don't forget to apply settings.
424 system.ApplySettings(); 425 system->ApplySettings();
425 config->Save(); 426 config->Save();
426 427
427 UpdateStatusButtons(); 428 UpdateStatusButtons();
@@ -455,7 +456,7 @@ void GMainWindow::SoftwareKeyboardInitialize(
455 return; 456 return;
456 } 457 }
457 458
458 software_keyboard = new QtSoftwareKeyboardDialog(render_window, system, is_inline, 459 software_keyboard = new QtSoftwareKeyboardDialog(render_window, *system, is_inline,
459 std::move(initialize_parameters)); 460 std::move(initialize_parameters));
460 461
461 if (is_inline) { 462 if (is_inline) {
@@ -567,7 +568,7 @@ void GMainWindow::WebBrowserOpenWebPage(const std::string& main_url,
567 return; 568 return;
568 } 569 }
569 570
570 QtNXWebEngineView web_browser_view(this, system, input_subsystem.get()); 571 QtNXWebEngineView web_browser_view(this, *system, input_subsystem.get());
571 572
572 ui->action_Pause->setEnabled(false); 573 ui->action_Pause->setEnabled(false);
573 ui->action_Restart->setEnabled(false); 574 ui->action_Restart->setEnabled(false);
@@ -699,10 +700,10 @@ void GMainWindow::InitializeWidgets() {
699#ifdef YUZU_ENABLE_COMPATIBILITY_REPORTING 700#ifdef YUZU_ENABLE_COMPATIBILITY_REPORTING
700 ui->action_Report_Compatibility->setVisible(true); 701 ui->action_Report_Compatibility->setVisible(true);
701#endif 702#endif
702 render_window = new GRenderWindow(this, emu_thread.get(), input_subsystem, system); 703 render_window = new GRenderWindow(this, emu_thread.get(), input_subsystem, *system);
703 render_window->hide(); 704 render_window->hide();
704 705
705 game_list = new GameList(vfs, provider.get(), system, this); 706 game_list = new GameList(vfs, provider.get(), *system, this);
706 ui->horizontalLayout->addWidget(game_list); 707 ui->horizontalLayout->addWidget(game_list);
707 708
708 game_list_placeholder = new GameListPlaceholder(this); 709 game_list_placeholder = new GameListPlaceholder(this);
@@ -768,14 +769,14 @@ void GMainWindow::InitializeWidgets() {
768 tr("Handheld controller can't be used on docked mode. Pro " 769 tr("Handheld controller can't be used on docked mode. Pro "
769 "controller will be selected.")); 770 "controller will be selected."));
770 controller_type = Settings::ControllerType::ProController; 771 controller_type = Settings::ControllerType::ProController;
771 ConfigureDialog configure_dialog(this, hotkey_registry, input_subsystem.get(), system); 772 ConfigureDialog configure_dialog(this, hotkey_registry, input_subsystem.get(), *system);
772 configure_dialog.ApplyConfiguration(); 773 configure_dialog.ApplyConfiguration();
773 controller_dialog->refreshConfiguration(); 774 controller_dialog->refreshConfiguration();
774 } 775 }
775 776
776 Settings::values.use_docked_mode.SetValue(!is_docked); 777 Settings::values.use_docked_mode.SetValue(!is_docked);
777 dock_status_button->setChecked(!is_docked); 778 dock_status_button->setChecked(!is_docked);
778 OnDockedModeChanged(is_docked, !is_docked, system); 779 OnDockedModeChanged(is_docked, !is_docked, *system);
779 }); 780 });
780 dock_status_button->setText(tr("DOCK")); 781 dock_status_button->setText(tr("DOCK"));
781 dock_status_button->setCheckable(true); 782 dock_status_button->setCheckable(true);
@@ -799,7 +800,7 @@ void GMainWindow::InitializeWidgets() {
799 } 800 }
800 } 801 }
801 802
802 system.ApplySettings(); 803 system->ApplySettings();
803 UpdateGPUAccuracyButton(); 804 UpdateGPUAccuracyButton();
804 }); 805 });
805 UpdateGPUAccuracyButton(); 806 UpdateGPUAccuracyButton();
@@ -827,7 +828,7 @@ void GMainWindow::InitializeWidgets() {
827 Settings::values.renderer_backend.SetValue(Settings::RendererBackend::OpenGL); 828 Settings::values.renderer_backend.SetValue(Settings::RendererBackend::OpenGL);
828 } 829 }
829 830
830 system.ApplySettings(); 831 system->ApplySettings();
831 }); 832 });
832 statusBar()->insertPermanentWidget(0, renderer_status_button); 833 statusBar()->insertPermanentWidget(0, renderer_status_button);
833 834
@@ -844,7 +845,7 @@ void GMainWindow::InitializeDebugWidgets() {
844 debug_menu->addAction(microProfileDialog->toggleViewAction()); 845 debug_menu->addAction(microProfileDialog->toggleViewAction());
845#endif 846#endif
846 847
847 waitTreeWidget = new WaitTreeWidget(system, this); 848 waitTreeWidget = new WaitTreeWidget(*system, this);
848 addDockWidget(Qt::LeftDockWidgetArea, waitTreeWidget); 849 addDockWidget(Qt::LeftDockWidgetArea, waitTreeWidget);
849 waitTreeWidget->hide(); 850 waitTreeWidget->hide();
850 debug_menu->addAction(waitTreeWidget->toggleViewAction()); 851 debug_menu->addAction(waitTreeWidget->toggleViewAction());
@@ -947,7 +948,7 @@ void GMainWindow::InitializeHotkeys() {
947 }); 948 });
948 connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("Restart Emulation"), this), 949 connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("Restart Emulation"), this),
949 &QShortcut::activated, this, [this] { 950 &QShortcut::activated, this, [this] {
950 if (!system.IsPoweredOn()) { 951 if (!system->IsPoweredOn()) {
951 return; 952 return;
952 } 953 }
953 BootGame(game_path); 954 BootGame(game_path);
@@ -1003,7 +1004,7 @@ void GMainWindow::InitializeHotkeys() {
1003 Settings::values.use_docked_mode.SetValue( 1004 Settings::values.use_docked_mode.SetValue(
1004 !Settings::values.use_docked_mode.GetValue()); 1005 !Settings::values.use_docked_mode.GetValue());
1005 OnDockedModeChanged(!Settings::values.use_docked_mode.GetValue(), 1006 OnDockedModeChanged(!Settings::values.use_docked_mode.GetValue(),
1006 Settings::values.use_docked_mode.GetValue(), system); 1007 Settings::values.use_docked_mode.GetValue(), *system);
1007 dock_status_button->setChecked(Settings::values.use_docked_mode.GetValue()); 1008 dock_status_button->setChecked(Settings::values.use_docked_mode.GetValue());
1008 }); 1009 });
1009 connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("Mute Audio"), this), 1010 connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("Mute Audio"), this),
@@ -1240,9 +1241,9 @@ bool GMainWindow::LoadROM(const QString& filename, u64 program_id, std::size_t p
1240 return false; 1241 return false;
1241 } 1242 }
1242 1243
1243 system.SetFilesystem(vfs); 1244 system->SetFilesystem(vfs);
1244 1245
1245 system.SetAppletFrontendSet({ 1246 system->SetAppletFrontendSet({
1246 std::make_unique<QtControllerSelector>(*this), // Controller Selector 1247 std::make_unique<QtControllerSelector>(*this), // Controller Selector
1247 std::make_unique<QtErrorDisplay>(*this), // Error Display 1248 std::make_unique<QtErrorDisplay>(*this), // Error Display
1248 nullptr, // Parental Controls 1249 nullptr, // Parental Controls
@@ -1252,14 +1253,14 @@ bool GMainWindow::LoadROM(const QString& filename, u64 program_id, std::size_t p
1252 std::make_unique<QtWebBrowser>(*this), // Web Browser 1253 std::make_unique<QtWebBrowser>(*this), // Web Browser
1253 }); 1254 });
1254 1255
1255 const Core::System::ResultStatus result{ 1256 const Core::SystemResultStatus result{
1256 system.Load(*render_window, filename.toStdString(), program_id, program_index)}; 1257 system->Load(*render_window, filename.toStdString(), program_id, program_index)};
1257 1258
1258 const auto drd_callout = (UISettings::values.callout_flags.GetValue() & 1259 const auto drd_callout = (UISettings::values.callout_flags.GetValue() &
1259 static_cast<u32>(CalloutFlag::DRDDeprecation)) == 0; 1260 static_cast<u32>(CalloutFlag::DRDDeprecation)) == 0;
1260 1261
1261 if (result == Core::System::ResultStatus::Success && 1262 if (result == Core::SystemResultStatus::Success &&
1262 system.GetAppLoader().GetFileType() == Loader::FileType::DeconstructedRomDirectory && 1263 system->GetAppLoader().GetFileType() == Loader::FileType::DeconstructedRomDirectory &&
1263 drd_callout) { 1264 drd_callout) {
1264 UISettings::values.callout_flags = UISettings::values.callout_flags.GetValue() | 1265 UISettings::values.callout_flags = UISettings::values.callout_flags.GetValue() |
1265 static_cast<u32>(CalloutFlag::DRDDeprecation); 1266 static_cast<u32>(CalloutFlag::DRDDeprecation);
@@ -1273,14 +1274,14 @@ bool GMainWindow::LoadROM(const QString& filename, u64 program_id, std::size_t p
1273 "wiki</a>. This message will not be shown again.")); 1274 "wiki</a>. This message will not be shown again."));
1274 } 1275 }
1275 1276
1276 if (result != Core::System::ResultStatus::Success) { 1277 if (result != Core::SystemResultStatus::Success) {
1277 switch (result) { 1278 switch (result) {
1278 case Core::System::ResultStatus::ErrorGetLoader: 1279 case Core::SystemResultStatus::ErrorGetLoader:
1279 LOG_CRITICAL(Frontend, "Failed to obtain loader for {}!", filename.toStdString()); 1280 LOG_CRITICAL(Frontend, "Failed to obtain loader for {}!", filename.toStdString());
1280 QMessageBox::critical(this, tr("Error while loading ROM!"), 1281 QMessageBox::critical(this, tr("Error while loading ROM!"),
1281 tr("The ROM format is not supported.")); 1282 tr("The ROM format is not supported."));
1282 break; 1283 break;
1283 case Core::System::ResultStatus::ErrorVideoCore: 1284 case Core::SystemResultStatus::ErrorVideoCore:
1284 QMessageBox::critical( 1285 QMessageBox::critical(
1285 this, tr("An error occurred initializing the video core."), 1286 this, tr("An error occurred initializing the video core."),
1286 tr("yuzu has encountered an error while running the video core, please see the " 1287 tr("yuzu has encountered an error while running the video core, please see the "
@@ -1294,8 +1295,8 @@ bool GMainWindow::LoadROM(const QString& filename, u64 program_id, std::size_t p
1294 break; 1295 break;
1295 1296
1296 default: 1297 default:
1297 if (result > Core::System::ResultStatus::ErrorLoader) { 1298 if (result > Core::SystemResultStatus::ErrorLoader) {
1298 const u16 loader_id = static_cast<u16>(Core::System::ResultStatus::ErrorLoader); 1299 const u16 loader_id = static_cast<u16>(Core::SystemResultStatus::ErrorLoader);
1299 const u16 error_id = static_cast<u16>(result) - loader_id; 1300 const u16 error_id = static_cast<u16>(result) - loader_id;
1300 const std::string error_code = fmt::format("({:04X}-{:04X})", loader_id, error_id); 1301 const std::string error_code = fmt::format("({:04X}-{:04X})", loader_id, error_id);
1301 LOG_CRITICAL(Frontend, "Failed to load ROM! {}", error_code); 1302 LOG_CRITICAL(Frontend, "Failed to load ROM! {}", error_code);
@@ -1323,7 +1324,7 @@ bool GMainWindow::LoadROM(const QString& filename, u64 program_id, std::size_t p
1323 } 1324 }
1324 game_path = filename; 1325 game_path = filename;
1325 1326
1326 system.TelemetrySession().AddField(Common::Telemetry::FieldType::App, "Frontend", "Qt"); 1327 system->TelemetrySession().AddField(Common::Telemetry::FieldType::App, "Frontend", "Qt");
1327 return true; 1328 return true;
1328} 1329}
1329 1330
@@ -1350,7 +1351,7 @@ void GMainWindow::BootGame(const QString& filename, u64 program_id, std::size_t
1350 last_filename_booted = filename; 1351 last_filename_booted = filename;
1351 1352
1352 const auto v_file = Core::GetGameFileFromPath(vfs, filename.toUtf8().constData()); 1353 const auto v_file = Core::GetGameFileFromPath(vfs, filename.toUtf8().constData());
1353 const auto loader = Loader::GetLoader(system, v_file, program_id, program_index); 1354 const auto loader = Loader::GetLoader(*system, v_file, program_id, program_index);
1354 1355
1355 if (loader != nullptr && loader->ReadProgramId(title_id) == Loader::ResultStatus::Success && 1356 if (loader != nullptr && loader->ReadProgramId(title_id) == Loader::ResultStatus::Success &&
1356 type == StartGameType::Normal) { 1357 type == StartGameType::Normal) {
@@ -1359,7 +1360,7 @@ void GMainWindow::BootGame(const QString& filename, u64 program_id, std::size_t
1359 const auto config_file_name = title_id == 0 1360 const auto config_file_name = title_id == 0
1360 ? Common::FS::PathToUTF8String(file_path.filename()) 1361 ? Common::FS::PathToUTF8String(file_path.filename())
1361 : fmt::format("{:016X}", title_id); 1362 : fmt::format("{:016X}", title_id);
1362 Config per_game_config(system, config_file_name, Config::ConfigType::PerGameConfig); 1363 Config per_game_config(*system, config_file_name, Config::ConfigType::PerGameConfig);
1363 } 1364 }
1364 1365
1365 ConfigureVibration::SetAllVibrationDevices(); 1366 ConfigureVibration::SetAllVibrationDevices();
@@ -1382,16 +1383,16 @@ void GMainWindow::BootGame(const QString& filename, u64 program_id, std::size_t
1382 return; 1383 return;
1383 1384
1384 // Create and start the emulation thread 1385 // Create and start the emulation thread
1385 emu_thread = std::make_unique<EmuThread>(system); 1386 emu_thread = std::make_unique<EmuThread>(*system);
1386 emit EmulationStarting(emu_thread.get()); 1387 emit EmulationStarting(emu_thread.get());
1387 emu_thread->start(); 1388 emu_thread->start();
1388 1389
1389 // Register an ExecuteProgram callback such that Core can execute a sub-program 1390 // Register an ExecuteProgram callback such that Core can execute a sub-program
1390 system.RegisterExecuteProgramCallback( 1391 system->RegisterExecuteProgramCallback(
1391 [this](std::size_t program_index) { render_window->ExecuteProgram(program_index); }); 1392 [this](std::size_t program_index) { render_window->ExecuteProgram(program_index); });
1392 1393
1393 // Register an Exit callback such that Core can exit the currently running application. 1394 // Register an Exit callback such that Core can exit the currently running application.
1394 system.RegisterExitCallback([this]() { render_window->Exit(); }); 1395 system->RegisterExitCallback([this]() { render_window->Exit(); });
1395 1396
1396 connect(render_window, &GRenderWindow::Closed, this, &GMainWindow::OnStopGame); 1397 connect(render_window, &GRenderWindow::Closed, this, &GMainWindow::OnStopGame);
1397 connect(render_window, &GRenderWindow::MouseActivity, this, &GMainWindow::OnMouseActivity); 1398 connect(render_window, &GRenderWindow::MouseActivity, this, &GMainWindow::OnMouseActivity);
@@ -1425,11 +1426,11 @@ void GMainWindow::BootGame(const QString& filename, u64 program_id, std::size_t
1425 1426
1426 std::string title_name; 1427 std::string title_name;
1427 std::string title_version; 1428 std::string title_version;
1428 const auto res = system.GetGameName(title_name); 1429 const auto res = system->GetGameName(title_name);
1429 1430
1430 const auto metadata = [this, title_id] { 1431 const auto metadata = [this, title_id] {
1431 const FileSys::PatchManager pm(title_id, system.GetFileSystemController(), 1432 const FileSys::PatchManager pm(title_id, system->GetFileSystemController(),
1432 system.GetContentProvider()); 1433 system->GetContentProvider());
1433 return pm.GetControlMetadata(); 1434 return pm.GetControlMetadata();
1434 }(); 1435 }();
1435 if (metadata.first != nullptr) { 1436 if (metadata.first != nullptr) {
@@ -1440,16 +1441,16 @@ void GMainWindow::BootGame(const QString& filename, u64 program_id, std::size_t
1440 title_name = Common::FS::PathToUTF8String( 1441 title_name = Common::FS::PathToUTF8String(
1441 std::filesystem::path{filename.toStdU16String()}.filename()); 1442 std::filesystem::path{filename.toStdU16String()}.filename());
1442 } 1443 }
1443 const bool is_64bit = system.Kernel().CurrentProcess()->Is64BitProcess(); 1444 const bool is_64bit = system->Kernel().CurrentProcess()->Is64BitProcess();
1444 const auto instruction_set_suffix = is_64bit ? tr("(64-bit)") : tr("(32-bit)"); 1445 const auto instruction_set_suffix = is_64bit ? tr("(64-bit)") : tr("(32-bit)");
1445 title_name = tr("%1 %2", "%1 is the title name. %2 indicates if the title is 64-bit or 32-bit") 1446 title_name = tr("%1 %2", "%1 is the title name. %2 indicates if the title is 64-bit or 32-bit")
1446 .arg(QString::fromStdString(title_name), instruction_set_suffix) 1447 .arg(QString::fromStdString(title_name), instruction_set_suffix)
1447 .toStdString(); 1448 .toStdString();
1448 LOG_INFO(Frontend, "Booting game: {:016X} | {} | {}", title_id, title_name, title_version); 1449 LOG_INFO(Frontend, "Booting game: {:016X} | {} | {}", title_id, title_name, title_version);
1449 const auto gpu_vendor = system.GPU().Renderer().GetDeviceVendor(); 1450 const auto gpu_vendor = system->GPU().Renderer().GetDeviceVendor();
1450 UpdateWindowTitle(title_name, title_version, gpu_vendor); 1451 UpdateWindowTitle(title_name, title_version, gpu_vendor);
1451 1452
1452 loading_screen->Prepare(system.GetAppLoader()); 1453 loading_screen->Prepare(system->GetAppLoader());
1453 loading_screen->show(); 1454 loading_screen->show();
1454 1455
1455 emulation_running = true; 1456 emulation_running = true;
@@ -1568,15 +1569,15 @@ void GMainWindow::OnGameListOpenFolder(u64 program_id, GameListOpenTarget target
1568 QString open_target; 1569 QString open_target;
1569 1570
1570 const auto [user_save_size, device_save_size] = [this, &game_path, &program_id] { 1571 const auto [user_save_size, device_save_size] = [this, &game_path, &program_id] {
1571 const FileSys::PatchManager pm{program_id, system.GetFileSystemController(), 1572 const FileSys::PatchManager pm{program_id, system->GetFileSystemController(),
1572 system.GetContentProvider()}; 1573 system->GetContentProvider()};
1573 const auto control = pm.GetControlMetadata().first; 1574 const auto control = pm.GetControlMetadata().first;
1574 if (control != nullptr) { 1575 if (control != nullptr) {
1575 return std::make_pair(control->GetDefaultNormalSaveSize(), 1576 return std::make_pair(control->GetDefaultNormalSaveSize(),
1576 control->GetDeviceSaveDataSize()); 1577 control->GetDeviceSaveDataSize());
1577 } else { 1578 } else {
1578 const auto file = Core::GetGameFileFromPath(vfs, game_path); 1579 const auto file = Core::GetGameFileFromPath(vfs, game_path);
1579 const auto loader = Loader::GetLoader(system, file); 1580 const auto loader = Loader::GetLoader(*system, file);
1580 1581
1581 FileSys::NACP nacp{}; 1582 FileSys::NACP nacp{};
1582 loader->ReadControlData(nacp); 1583 loader->ReadControlData(nacp);
@@ -1619,14 +1620,14 @@ void GMainWindow::OnGameListOpenFolder(u64 program_id, GameListOpenTarget target
1619 ASSERT(user_id); 1620 ASSERT(user_id);
1620 1621
1621 const auto user_save_data_path = FileSys::SaveDataFactory::GetFullPath( 1622 const auto user_save_data_path = FileSys::SaveDataFactory::GetFullPath(
1622 system, FileSys::SaveDataSpaceId::NandUser, FileSys::SaveDataType::SaveData, 1623 *system, FileSys::SaveDataSpaceId::NandUser, FileSys::SaveDataType::SaveData,
1623 program_id, user_id->uuid, 0); 1624 program_id, user_id->uuid, 0);
1624 1625
1625 path = Common::FS::ConcatPathSafe(nand_dir, user_save_data_path); 1626 path = Common::FS::ConcatPathSafe(nand_dir, user_save_data_path);
1626 } else { 1627 } else {
1627 // Device save data 1628 // Device save data
1628 const auto device_save_data_path = FileSys::SaveDataFactory::GetFullPath( 1629 const auto device_save_data_path = FileSys::SaveDataFactory::GetFullPath(
1629 system, FileSys::SaveDataSpaceId::NandUser, FileSys::SaveDataType::SaveData, 1630 *system, FileSys::SaveDataSpaceId::NandUser, FileSys::SaveDataType::SaveData,
1630 program_id, {}, 0); 1631 program_id, {}, 0);
1631 1632
1632 path = Common::FS::ConcatPathSafe(nand_dir, device_save_data_path); 1633 path = Common::FS::ConcatPathSafe(nand_dir, device_save_data_path);
@@ -1753,7 +1754,7 @@ void GMainWindow::OnGameListRemoveInstalledEntry(u64 program_id, InstalledEntryT
1753} 1754}
1754 1755
1755void GMainWindow::RemoveBaseContent(u64 program_id, const QString& entry_type) { 1756void GMainWindow::RemoveBaseContent(u64 program_id, const QString& entry_type) {
1756 const auto& fs_controller = system.GetFileSystemController(); 1757 const auto& fs_controller = system->GetFileSystemController();
1757 const auto res = fs_controller.GetUserNANDContents()->RemoveExistingEntry(program_id) || 1758 const auto res = fs_controller.GetUserNANDContents()->RemoveExistingEntry(program_id) ||
1758 fs_controller.GetSDMCContents()->RemoveExistingEntry(program_id); 1759 fs_controller.GetSDMCContents()->RemoveExistingEntry(program_id);
1759 1760
@@ -1769,7 +1770,7 @@ void GMainWindow::RemoveBaseContent(u64 program_id, const QString& entry_type) {
1769 1770
1770void GMainWindow::RemoveUpdateContent(u64 program_id, const QString& entry_type) { 1771void GMainWindow::RemoveUpdateContent(u64 program_id, const QString& entry_type) {
1771 const auto update_id = program_id | 0x800; 1772 const auto update_id = program_id | 0x800;
1772 const auto& fs_controller = system.GetFileSystemController(); 1773 const auto& fs_controller = system->GetFileSystemController();
1773 const auto res = fs_controller.GetUserNANDContents()->RemoveExistingEntry(update_id) || 1774 const auto res = fs_controller.GetUserNANDContents()->RemoveExistingEntry(update_id) ||
1774 fs_controller.GetSDMCContents()->RemoveExistingEntry(update_id); 1775 fs_controller.GetSDMCContents()->RemoveExistingEntry(update_id);
1775 1776
@@ -1784,8 +1785,8 @@ void GMainWindow::RemoveUpdateContent(u64 program_id, const QString& entry_type)
1784 1785
1785void GMainWindow::RemoveAddOnContent(u64 program_id, const QString& entry_type) { 1786void GMainWindow::RemoveAddOnContent(u64 program_id, const QString& entry_type) {
1786 u32 count{}; 1787 u32 count{};
1787 const auto& fs_controller = system.GetFileSystemController(); 1788 const auto& fs_controller = system->GetFileSystemController();
1788 const auto dlc_entries = system.GetContentProvider().ListEntriesFilter( 1789 const auto dlc_entries = system->GetContentProvider().ListEntriesFilter(
1789 FileSys::TitleType::AOC, FileSys::ContentRecordType::Data); 1790 FileSys::TitleType::AOC, FileSys::ContentRecordType::Data);
1790 1791
1791 for (const auto& entry : dlc_entries) { 1792 for (const auto& entry : dlc_entries) {
@@ -1923,7 +1924,7 @@ void GMainWindow::OnGameListDumpRomFS(u64 program_id, const std::string& game_pa
1923 "cancelled the operation.")); 1924 "cancelled the operation."));
1924 }; 1925 };
1925 1926
1926 const auto loader = Loader::GetLoader(system, vfs->OpenFile(game_path, FileSys::Mode::Read)); 1927 const auto loader = Loader::GetLoader(*system, vfs->OpenFile(game_path, FileSys::Mode::Read));
1927 if (loader == nullptr) { 1928 if (loader == nullptr) {
1928 failed(); 1929 failed();
1929 return; 1930 return;
@@ -1935,7 +1936,7 @@ void GMainWindow::OnGameListDumpRomFS(u64 program_id, const std::string& game_pa
1935 return; 1936 return;
1936 } 1937 }
1937 1938
1938 const auto& installed = system.GetContentProvider(); 1939 const auto& installed = system->GetContentProvider();
1939 const auto romfs_title_id = SelectRomFSDumpTarget(installed, program_id); 1940 const auto romfs_title_id = SelectRomFSDumpTarget(installed, program_id);
1940 1941
1941 if (!romfs_title_id) { 1942 if (!romfs_title_id) {
@@ -1955,7 +1956,7 @@ void GMainWindow::OnGameListDumpRomFS(u64 program_id, const std::string& game_pa
1955 1956
1956 if (*romfs_title_id == program_id) { 1957 if (*romfs_title_id == program_id) {
1957 const u64 ivfc_offset = loader->ReadRomFSIVFCOffset(); 1958 const u64 ivfc_offset = loader->ReadRomFSIVFCOffset();
1958 const FileSys::PatchManager pm{program_id, system.GetFileSystemController(), installed}; 1959 const FileSys::PatchManager pm{program_id, system->GetFileSystemController(), installed};
1959 romfs = 1960 romfs =
1960 pm.PatchRomFS(file, ivfc_offset, FileSys::ContentRecordType::Program, nullptr, false); 1961 pm.PatchRomFS(file, ivfc_offset, FileSys::ContentRecordType::Program, nullptr, false);
1961 } else { 1962 } else {
@@ -2090,7 +2091,7 @@ void GMainWindow::OnGameListShowList(bool show) {
2090void GMainWindow::OnGameListOpenPerGameProperties(const std::string& file) { 2091void GMainWindow::OnGameListOpenPerGameProperties(const std::string& file) {
2091 u64 title_id{}; 2092 u64 title_id{};
2092 const auto v_file = Core::GetGameFileFromPath(vfs, file); 2093 const auto v_file = Core::GetGameFileFromPath(vfs, file);
2093 const auto loader = Loader::GetLoader(system, v_file); 2094 const auto loader = Loader::GetLoader(*system, v_file);
2094 2095
2095 if (loader == nullptr || loader->ReadProgramId(title_id) != Loader::ResultStatus::Success) { 2096 if (loader == nullptr || loader->ReadProgramId(title_id) != Loader::ResultStatus::Success) {
2096 QMessageBox::information(this, tr("Properties"), 2097 QMessageBox::information(this, tr("Properties"),
@@ -2304,7 +2305,7 @@ InstallResult GMainWindow::InstallNSPXCI(const QString& filename) {
2304 if (nsp->GetStatus() != Loader::ResultStatus::Success) { 2305 if (nsp->GetStatus() != Loader::ResultStatus::Success) {
2305 return InstallResult::Failure; 2306 return InstallResult::Failure;
2306 } 2307 }
2307 const auto res = system.GetFileSystemController().GetUserNANDContents()->InstallEntry( 2308 const auto res = system->GetFileSystemController().GetUserNANDContents()->InstallEntry(
2308 *nsp, true, qt_raw_copy); 2309 *nsp, true, qt_raw_copy);
2309 switch (res) { 2310 switch (res) {
2310 case FileSys::InstallResult::Success: 2311 case FileSys::InstallResult::Success:
@@ -2384,7 +2385,7 @@ InstallResult GMainWindow::InstallNCA(const QString& filename) {
2384 } 2385 }
2385 2386
2386 const bool is_application = index >= static_cast<s32>(FileSys::TitleType::Application); 2387 const bool is_application = index >= static_cast<s32>(FileSys::TitleType::Application);
2387 const auto& fs_controller = system.GetFileSystemController(); 2388 const auto& fs_controller = system->GetFileSystemController();
2388 auto* registered_cache = is_application ? fs_controller.GetUserNANDContents() 2389 auto* registered_cache = is_application ? fs_controller.GetUserNANDContents()
2389 : fs_controller.GetSystemNANDContents(); 2390 : fs_controller.GetSystemNANDContents();
2390 2391
@@ -2449,13 +2450,13 @@ void GMainWindow::OnPauseGame() {
2449} 2450}
2450 2451
2451void GMainWindow::OnStopGame() { 2452void GMainWindow::OnStopGame() {
2452 if (system.GetExitLock() && !ConfirmForceLockedExit()) { 2453 if (system->GetExitLock() && !ConfirmForceLockedExit()) {
2453 return; 2454 return;
2454 } 2455 }
2455 2456
2456 ShutdownGame(); 2457 ShutdownGame();
2457 2458
2458 Settings::RestoreGlobalState(system.IsPoweredOn()); 2459 Settings::RestoreGlobalState(system->IsPoweredOn());
2459 UpdateStatusButtons(); 2460 UpdateStatusButtons();
2460} 2461}
2461 2462
@@ -2473,7 +2474,7 @@ void GMainWindow::OnExit() {
2473} 2474}
2474 2475
2475void GMainWindow::ErrorDisplayDisplayError(QString error_code, QString error_text) { 2476void GMainWindow::ErrorDisplayDisplayError(QString error_code, QString error_text) {
2476 OverlayDialog dialog(render_window, system, error_code, error_text, QString{}, tr("OK"), 2477 OverlayDialog dialog(render_window, *system, error_code, error_text, QString{}, tr("OK"),
2477 Qt::AlignLeft | Qt::AlignVCenter); 2478 Qt::AlignLeft | Qt::AlignVCenter);
2478 dialog.exec(); 2479 dialog.exec();
2479 2480
@@ -2483,7 +2484,7 @@ void GMainWindow::ErrorDisplayDisplayError(QString error_code, QString error_tex
2483void GMainWindow::OnMenuReportCompatibility() { 2484void GMainWindow::OnMenuReportCompatibility() {
2484 if (!Settings::values.yuzu_token.GetValue().empty() && 2485 if (!Settings::values.yuzu_token.GetValue().empty() &&
2485 !Settings::values.yuzu_username.GetValue().empty()) { 2486 !Settings::values.yuzu_username.GetValue().empty()) {
2486 CompatDB compatdb{system.TelemetrySession(), this}; 2487 CompatDB compatdb{system->TelemetrySession(), this};
2487 compatdb.exec(); 2488 compatdb.exec();
2488 } else { 2489 } else {
2489 QMessageBox::critical( 2490 QMessageBox::critical(
@@ -2647,7 +2648,7 @@ void GMainWindow::OnConfigure() {
2647 const bool old_discord_presence = UISettings::values.enable_discord_presence.GetValue(); 2648 const bool old_discord_presence = UISettings::values.enable_discord_presence.GetValue();
2648 2649
2649 Settings::SetConfiguringGlobal(true); 2650 Settings::SetConfiguringGlobal(true);
2650 ConfigureDialog configure_dialog(this, hotkey_registry, input_subsystem.get(), system); 2651 ConfigureDialog configure_dialog(this, hotkey_registry, input_subsystem.get(), *system);
2651 connect(&configure_dialog, &ConfigureDialog::LanguageChanged, this, 2652 connect(&configure_dialog, &ConfigureDialog::LanguageChanged, this,
2652 &GMainWindow::OnLanguageChanged); 2653 &GMainWindow::OnLanguageChanged);
2653 2654
@@ -2683,7 +2684,7 @@ void GMainWindow::OnConfigure() {
2683 2684
2684 Settings::values.disabled_addons.clear(); 2685 Settings::values.disabled_addons.clear();
2685 2686
2686 config = std::make_unique<Config>(system); 2687 config = std::make_unique<Config>(*system);
2687 UISettings::values.reset_to_defaults = false; 2688 UISettings::values.reset_to_defaults = false;
2688 2689
2689 UISettings::values.game_dirs = std::move(old_game_dirs); 2690 UISettings::values.game_dirs = std::move(old_game_dirs);
@@ -2732,12 +2733,11 @@ void GMainWindow::OnConfigure() {
2732} 2733}
2733 2734
2734void GMainWindow::OnConfigureTas() { 2735void GMainWindow::OnConfigureTas() {
2735 const auto& system = Core::System::GetInstance();
2736 ConfigureTasDialog dialog(this); 2736 ConfigureTasDialog dialog(this);
2737 const auto result = dialog.exec(); 2737 const auto result = dialog.exec();
2738 2738
2739 if (result != QDialog::Accepted && !UISettings::values.configuration_applied) { 2739 if (result != QDialog::Accepted && !UISettings::values.configuration_applied) {
2740 Settings::RestoreGlobalState(system.IsPoweredOn()); 2740 Settings::RestoreGlobalState(system->IsPoweredOn());
2741 return; 2741 return;
2742 } else if (result == QDialog::Accepted) { 2742 } else if (result == QDialog::Accepted) {
2743 dialog.ApplyConfiguration(); 2743 dialog.ApplyConfiguration();
@@ -2745,7 +2745,7 @@ void GMainWindow::OnConfigureTas() {
2745} 2745}
2746 2746
2747void GMainWindow::OnConfigurePerGame() { 2747void GMainWindow::OnConfigurePerGame() {
2748 const u64 title_id = system.CurrentProcess()->GetTitleID(); 2748 const u64 title_id = system->CurrentProcess()->GetTitleID();
2749 OpenPerGameConfiguration(title_id, game_path.toStdString()); 2749 OpenPerGameConfiguration(title_id, game_path.toStdString());
2750} 2750}
2751 2751
@@ -2753,12 +2753,12 @@ void GMainWindow::OpenPerGameConfiguration(u64 title_id, const std::string& file
2753 const auto v_file = Core::GetGameFileFromPath(vfs, file_name); 2753 const auto v_file = Core::GetGameFileFromPath(vfs, file_name);
2754 2754
2755 Settings::SetConfiguringGlobal(false); 2755 Settings::SetConfiguringGlobal(false);
2756 ConfigurePerGame dialog(this, title_id, file_name, system); 2756 ConfigurePerGame dialog(this, title_id, file_name, *system);
2757 dialog.LoadFromFile(v_file); 2757 dialog.LoadFromFile(v_file);
2758 const auto result = dialog.exec(); 2758 const auto result = dialog.exec();
2759 2759
2760 if (result != QDialog::Accepted && !UISettings::values.configuration_applied) { 2760 if (result != QDialog::Accepted && !UISettings::values.configuration_applied) {
2761 Settings::RestoreGlobalState(system.IsPoweredOn()); 2761 Settings::RestoreGlobalState(system->IsPoweredOn());
2762 return; 2762 return;
2763 } else if (result == QDialog::Accepted) { 2763 } else if (result == QDialog::Accepted) {
2764 dialog.ApplyConfiguration(); 2764 dialog.ApplyConfiguration();
@@ -2770,7 +2770,7 @@ void GMainWindow::OpenPerGameConfiguration(u64 title_id, const std::string& file
2770 } 2770 }
2771 2771
2772 // Do not cause the global config to write local settings into the config file 2772 // Do not cause the global config to write local settings into the config file
2773 const bool is_powered_on = system.IsPoweredOn(); 2773 const bool is_powered_on = system->IsPoweredOn();
2774 Settings::RestoreGlobalState(is_powered_on); 2774 Settings::RestoreGlobalState(is_powered_on);
2775 2775
2776 UISettings::values.configuration_applied = false; 2776 UISettings::values.configuration_applied = false;
@@ -2793,7 +2793,7 @@ void GMainWindow::OnLoadAmiibo() {
2793} 2793}
2794 2794
2795void GMainWindow::LoadAmiibo(const QString& filename) { 2795void GMainWindow::LoadAmiibo(const QString& filename) {
2796 Service::SM::ServiceManager& sm = system.ServiceManager(); 2796 Service::SM::ServiceManager& sm = system->ServiceManager();
2797 auto nfc = sm.GetService<Service::NFP::Module::Interface>("nfp:user"); 2797 auto nfc = sm.GetService<Service::NFP::Module::Interface>("nfp:user");
2798 if (nfc == nullptr) { 2798 if (nfc == nullptr) {
2799 return; 2799 return;
@@ -2844,7 +2844,7 @@ void GMainWindow::OnToggleFilterBar() {
2844} 2844}
2845 2845
2846void GMainWindow::OnCaptureScreenshot() { 2846void GMainWindow::OnCaptureScreenshot() {
2847 const u64 title_id = system.CurrentProcess()->GetTitleID(); 2847 const u64 title_id = system->CurrentProcess()->GetTitleID();
2848 const auto screenshot_path = 2848 const auto screenshot_path =
2849 QString::fromStdString(Common::FS::GetYuzuPathString(Common::FS::YuzuPath::ScreenshotsDir)); 2849 QString::fromStdString(Common::FS::GetYuzuPathString(Common::FS::YuzuPath::ScreenshotsDir));
2850 const auto date = 2850 const auto date =
@@ -2950,8 +2950,8 @@ void GMainWindow::UpdateStatusBar() {
2950 tas_label->clear(); 2950 tas_label->clear();
2951 } 2951 }
2952 2952
2953 auto results = system.GetAndResetPerfStats(); 2953 auto results = system->GetAndResetPerfStats();
2954 auto& shader_notify = system.GPU().ShaderNotify(); 2954 auto& shader_notify = system->GPU().ShaderNotify();
2955 const int shaders_building = shader_notify.ShadersBuilding(); 2955 const int shaders_building = shader_notify.ShadersBuilding();
2956 2956
2957 if (shaders_building > 0) { 2957 if (shaders_building > 0) {
@@ -3052,7 +3052,7 @@ void GMainWindow::OnMouseActivity() {
3052 } 3052 }
3053} 3053}
3054 3054
3055void GMainWindow::OnCoreError(Core::System::ResultStatus result, std::string details) { 3055void GMainWindow::OnCoreError(Core::SystemResultStatus result, std::string details) {
3056 QMessageBox::StandardButton answer; 3056 QMessageBox::StandardButton answer;
3057 QString status_message; 3057 QString status_message;
3058 const QString common_message = 3058 const QString common_message =
@@ -3067,7 +3067,7 @@ void GMainWindow::OnCoreError(Core::System::ResultStatus result, std::string det
3067 "back to the game list? Continuing emulation may result in crashes, corrupted save " 3067 "back to the game list? Continuing emulation may result in crashes, corrupted save "
3068 "data, or other bugs."); 3068 "data, or other bugs.");
3069 switch (result) { 3069 switch (result) {
3070 case Core::System::ResultStatus::ErrorSystemFiles: { 3070 case Core::SystemResultStatus::ErrorSystemFiles: {
3071 QString message; 3071 QString message;
3072 if (details.empty()) { 3072 if (details.empty()) {
3073 message = 3073 message =
@@ -3083,7 +3083,7 @@ void GMainWindow::OnCoreError(Core::System::ResultStatus result, std::string det
3083 break; 3083 break;
3084 } 3084 }
3085 3085
3086 case Core::System::ResultStatus::ErrorSharedFont: { 3086 case Core::SystemResultStatus::ErrorSharedFont: {
3087 const QString message = 3087 const QString message =
3088 tr("yuzu was unable to locate the Switch shared fonts. %1").arg(common_message); 3088 tr("yuzu was unable to locate the Switch shared fonts. %1").arg(common_message);
3089 answer = QMessageBox::question(this, tr("Shared Fonts Not Found"), message, 3089 answer = QMessageBox::question(this, tr("Shared Fonts Not Found"), message,
@@ -3112,7 +3112,7 @@ void GMainWindow::OnCoreError(Core::System::ResultStatus result, std::string det
3112 if (emu_thread) { 3112 if (emu_thread) {
3113 ShutdownGame(); 3113 ShutdownGame();
3114 3114
3115 Settings::RestoreGlobalState(system.IsPoweredOn()); 3115 Settings::RestoreGlobalState(system->IsPoweredOn());
3116 UpdateStatusButtons(); 3116 UpdateStatusButtons();
3117 } 3117 }
3118 } else { 3118 } else {
@@ -3154,8 +3154,8 @@ void GMainWindow::OnReinitializeKeys(ReinitializeKeyBehavior behavior) {
3154 const auto function = [this, &keys, &pdm] { 3154 const auto function = [this, &keys, &pdm] {
3155 keys.PopulateFromPartitionData(pdm); 3155 keys.PopulateFromPartitionData(pdm);
3156 3156
3157 system.GetFileSystemController().CreateFactories(*vfs); 3157 system->GetFileSystemController().CreateFactories(*vfs);
3158 keys.DeriveETicket(pdm, system.GetContentProvider()); 3158 keys.DeriveETicket(pdm, system->GetContentProvider());
3159 }; 3159 };
3160 3160
3161 QString errors; 3161 QString errors;
@@ -3197,7 +3197,7 @@ void GMainWindow::OnReinitializeKeys(ReinitializeKeyBehavior behavior) {
3197 prog.close(); 3197 prog.close();
3198 } 3198 }
3199 3199
3200 system.GetFileSystemController().CreateFactories(*vfs); 3200 system->GetFileSystemController().CreateFactories(*vfs);
3201 3201
3202 if (behavior == ReinitializeKeyBehavior::Warning) { 3202 if (behavior == ReinitializeKeyBehavior::Warning) {
3203 game_list->PopulateAsync(UISettings::values.game_dirs); 3203 game_list->PopulateAsync(UISettings::values.game_dirs);
@@ -3265,7 +3265,7 @@ void GMainWindow::closeEvent(QCloseEvent* event) {
3265 if (emu_thread != nullptr) { 3265 if (emu_thread != nullptr) {
3266 ShutdownGame(); 3266 ShutdownGame();
3267 3267
3268 Settings::RestoreGlobalState(system.IsPoweredOn()); 3268 Settings::RestoreGlobalState(system->IsPoweredOn());
3269 UpdateStatusButtons(); 3269 UpdateStatusButtons();
3270 } 3270 }
3271 3271
@@ -3340,7 +3340,7 @@ bool GMainWindow::ConfirmForceLockedExit() {
3340} 3340}
3341 3341
3342void GMainWindow::RequestGameExit() { 3342void GMainWindow::RequestGameExit() {
3343 auto& sm{system.ServiceManager()}; 3343 auto& sm{system->ServiceManager()};
3344 auto applet_oe = sm.GetService<Service::AM::AppletOE>("appletOE"); 3344 auto applet_oe = sm.GetService<Service::AM::AppletOE>("appletOE");
3345 auto applet_ae = sm.GetService<Service::AM::AppletAE>("appletAE"); 3345 auto applet_ae = sm.GetService<Service::AM::AppletAE>("appletAE");
3346 bool has_signalled = false; 3346 bool has_signalled = false;
@@ -3434,7 +3434,7 @@ void GMainWindow::OnLanguageChanged(const QString& locale) {
3434void GMainWindow::SetDiscordEnabled([[maybe_unused]] bool state) { 3434void GMainWindow::SetDiscordEnabled([[maybe_unused]] bool state) {
3435#ifdef USE_DISCORD_PRESENCE 3435#ifdef USE_DISCORD_PRESENCE
3436 if (state) { 3436 if (state) {
3437 discord_rpc = std::make_unique<DiscordRPC::DiscordImpl>(system); 3437 discord_rpc = std::make_unique<DiscordRPC::DiscordImpl>(*system);
3438 } else { 3438 } else {
3439 discord_rpc = std::make_unique<DiscordRPC::NullImpl>(); 3439 discord_rpc = std::make_unique<DiscordRPC::NullImpl>();
3440 } 3440 }
@@ -3488,8 +3488,7 @@ int main(int argc, char* argv[]) {
3488 // generating shaders 3488 // generating shaders
3489 setlocale(LC_ALL, "C"); 3489 setlocale(LC_ALL, "C");
3490 3490
3491 Core::System::InitializeGlobalInstance(); 3491 GMainWindow main_window{};
3492 GMainWindow main_window{Core::System::GetInstance()};
3493 // After settings have been loaded by GMainWindow, apply the filter 3492 // After settings have been loaded by GMainWindow, apply the filter
3494 main_window.show(); 3493 main_window.show();
3495 3494
diff --git a/src/yuzu/main.h b/src/yuzu/main.h
index f501cf400..aed15a0a0 100644
--- a/src/yuzu/main.h
+++ b/src/yuzu/main.h
@@ -13,7 +13,6 @@
13#include <QTranslator> 13#include <QTranslator>
14 14
15#include "common/common_types.h" 15#include "common/common_types.h"
16#include "core/core.h"
17#include "core/hle/service/acc/profile_manager.h" 16#include "core/hle/service/acc/profile_manager.h"
18#include "yuzu/compatibility_list.h" 17#include "yuzu/compatibility_list.h"
19#include "yuzu/hotkeys.h" 18#include "yuzu/hotkeys.h"
@@ -44,6 +43,11 @@ enum class StartGameType {
44 Global, // Only uses global configuration 43 Global, // Only uses global configuration
45}; 44};
46 45
46namespace Core {
47enum class SystemResultStatus : u32;
48class System;
49} // namespace Core
50
47namespace Core::Frontend { 51namespace Core::Frontend {
48struct ControllerParameters; 52struct ControllerParameters;
49struct InlineAppearParameters; 53struct InlineAppearParameters;
@@ -110,7 +114,7 @@ class GMainWindow : public QMainWindow {
110public: 114public:
111 void filterBarSetChecked(bool state); 115 void filterBarSetChecked(bool state);
112 void UpdateUITheme(); 116 void UpdateUITheme();
113 GMainWindow(Core::System& system_); 117 explicit GMainWindow();
114 ~GMainWindow() override; 118 ~GMainWindow() override;
115 119
116 bool DropAction(QDropEvent* event); 120 bool DropAction(QDropEvent* event);
@@ -280,7 +284,7 @@ private slots:
280 void ResetWindowSize900(); 284 void ResetWindowSize900();
281 void ResetWindowSize1080(); 285 void ResetWindowSize1080();
282 void OnCaptureScreenshot(); 286 void OnCaptureScreenshot();
283 void OnCoreError(Core::System::ResultStatus, std::string); 287 void OnCoreError(Core::SystemResultStatus, std::string);
284 void OnReinitializeKeys(ReinitializeKeyBehavior behavior); 288 void OnReinitializeKeys(ReinitializeKeyBehavior behavior);
285 void OnLanguageChanged(const QString& locale); 289 void OnLanguageChanged(const QString& locale);
286 void OnMouseActivity(); 290 void OnMouseActivity();
@@ -311,11 +315,10 @@ private:
311 315
312 std::unique_ptr<Ui::MainWindow> ui; 316 std::unique_ptr<Ui::MainWindow> ui;
313 317
318 std::unique_ptr<Core::System> system;
314 std::unique_ptr<DiscordRPC::DiscordInterface> discord_rpc; 319 std::unique_ptr<DiscordRPC::DiscordInterface> discord_rpc;
315 std::shared_ptr<InputCommon::InputSubsystem> input_subsystem; 320 std::shared_ptr<InputCommon::InputSubsystem> input_subsystem;
316 321
317 Core::System& system;
318
319 GRenderWindow* render_window; 322 GRenderWindow* render_window;
320 GameList* game_list; 323 GameList* game_list;
321 LoadingScreen* loading_screen; 324 LoadingScreen* loading_screen;
diff --git a/src/yuzu_cmd/yuzu.cpp b/src/yuzu_cmd/yuzu.cpp
index ba2c993ba..67587cc54 100644
--- a/src/yuzu_cmd/yuzu.cpp
+++ b/src/yuzu_cmd/yuzu.cpp
@@ -146,9 +146,8 @@ int main(int argc, char** argv) {
146 return -1; 146 return -1;
147 } 147 }
148 148
149 Core::System::InitializeGlobalInstance(); 149 Core::System system{};
150 auto& system{Core::System::GetInstance()}; 150 InputCommon::InputSubsystem input_subsystem{};
151 InputCommon::InputSubsystem input_subsystem;
152 151
153 // Apply the command line arguments 152 // Apply the command line arguments
154 system.ApplySettings(); 153 system.ApplySettings();
@@ -167,27 +166,27 @@ int main(int argc, char** argv) {
167 system.SetFilesystem(std::make_shared<FileSys::RealVfsFilesystem>()); 166 system.SetFilesystem(std::make_shared<FileSys::RealVfsFilesystem>());
168 system.GetFileSystemController().CreateFactories(*system.GetFilesystem()); 167 system.GetFileSystemController().CreateFactories(*system.GetFilesystem());
169 168
170 const Core::System::ResultStatus load_result{system.Load(*emu_window, filepath)}; 169 const Core::SystemResultStatus load_result{system.Load(*emu_window, filepath)};
171 170
172 switch (load_result) { 171 switch (load_result) {
173 case Core::System::ResultStatus::ErrorGetLoader: 172 case Core::SystemResultStatus::ErrorGetLoader:
174 LOG_CRITICAL(Frontend, "Failed to obtain loader for {}!", filepath); 173 LOG_CRITICAL(Frontend, "Failed to obtain loader for {}!", filepath);
175 return -1; 174 return -1;
176 case Core::System::ResultStatus::ErrorLoader: 175 case Core::SystemResultStatus::ErrorLoader:
177 LOG_CRITICAL(Frontend, "Failed to load ROM!"); 176 LOG_CRITICAL(Frontend, "Failed to load ROM!");
178 return -1; 177 return -1;
179 case Core::System::ResultStatus::ErrorNotInitialized: 178 case Core::SystemResultStatus::ErrorNotInitialized:
180 LOG_CRITICAL(Frontend, "CPUCore not initialized"); 179 LOG_CRITICAL(Frontend, "CPUCore not initialized");
181 return -1; 180 return -1;
182 case Core::System::ResultStatus::ErrorVideoCore: 181 case Core::SystemResultStatus::ErrorVideoCore:
183 LOG_CRITICAL(Frontend, "Failed to initialize VideoCore!"); 182 LOG_CRITICAL(Frontend, "Failed to initialize VideoCore!");
184 return -1; 183 return -1;
185 case Core::System::ResultStatus::Success: 184 case Core::SystemResultStatus::Success:
186 break; // Expected case 185 break; // Expected case
187 default: 186 default:
188 if (static_cast<u32>(load_result) > 187 if (static_cast<u32>(load_result) >
189 static_cast<u32>(Core::System::ResultStatus::ErrorLoader)) { 188 static_cast<u32>(Core::SystemResultStatus::ErrorLoader)) {
190 const u16 loader_id = static_cast<u16>(Core::System::ResultStatus::ErrorLoader); 189 const u16 loader_id = static_cast<u16>(Core::SystemResultStatus::ErrorLoader);
191 const u16 error_id = static_cast<u16>(load_result) - loader_id; 190 const u16 error_id = static_cast<u16>(load_result) - loader_id;
192 LOG_CRITICAL(Frontend, 191 LOG_CRITICAL(Frontend,
193 "While attempting to load the ROM requested, an error occurred. Please " 192 "While attempting to load the ROM requested, an error occurred. Please "