diff options
Diffstat (limited to 'src')
53 files changed, 549 insertions, 450 deletions
diff --git a/src/common/alignment.h b/src/common/alignment.h index 1b56569d17..8570c7d3c4 100644 --- a/src/common/alignment.h +++ b/src/common/alignment.h @@ -64,7 +64,7 @@ public: using propagate_on_container_copy_assignment = std::true_type; using propagate_on_container_move_assignment = std::true_type; using propagate_on_container_swap = std::true_type; - using is_always_equal = std::true_type; + using is_always_equal = std::false_type; constexpr AlignmentAllocator() noexcept = default; @@ -83,6 +83,11 @@ public: struct rebind { using other = AlignmentAllocator<T2, Align>; }; + + template <typename T2, size_t Align2> + constexpr bool operator==(const AlignmentAllocator<T2, Align2>&) const noexcept { + return std::is_same_v<T, T2> && Align == Align2; + } }; } // namespace Common diff --git a/src/common/settings.h b/src/common/settings.h index 402339443a..9ff4cf85db 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -7,7 +7,6 @@ #include <algorithm> #include <array> #include <atomic> -#include <chrono> #include <map> #include <optional> #include <string> @@ -487,9 +486,9 @@ struct Values { // System Setting<std::optional<u32>> rng_seed{std::optional<u32>(), "rng_seed"}; // Measured in seconds since epoch - std::optional<std::chrono::seconds> custom_rtc; + std::optional<s64> custom_rtc; // Set on game boot, reset on stop. Seconds difference between current time and `custom_rtc` - std::chrono::seconds custom_rtc_differential; + s64 custom_rtc_differential; BasicSetting<s32> current_user{0, "current_user"}; RangedSetting<s32> language_index{1, 0, 17, "language_index"}; diff --git a/src/common/string_util.cpp b/src/common/string_util.cpp index e6344fd415..6621711386 100644 --- a/src/common/string_util.cpp +++ b/src/common/string_util.cpp @@ -180,20 +180,20 @@ std::wstring UTF8ToUTF16W(const std::string& input) { #endif -std::string StringFromFixedZeroTerminatedBuffer(const char* buffer, std::size_t max_len) { +std::string StringFromFixedZeroTerminatedBuffer(std::string_view buffer, std::size_t max_len) { std::size_t len = 0; - while (len < max_len && buffer[len] != '\0') + while (len < buffer.length() && len < max_len && buffer[len] != '\0') { ++len; - - return std::string(buffer, len); + } + return std::string(buffer.begin(), buffer.begin() + len); } std::u16string UTF16StringFromFixedZeroTerminatedBuffer(std::u16string_view buffer, std::size_t max_len) { std::size_t len = 0; - while (len < max_len && buffer[len] != '\0') + while (len < buffer.length() && len < max_len && buffer[len] != '\0') { ++len; - + } return std::u16string(buffer.begin(), buffer.begin() + len); } diff --git a/src/common/string_util.h b/src/common/string_util.h index 7e90a9ca52..f0dd632eeb 100644 --- a/src/common/string_util.h +++ b/src/common/string_util.h @@ -63,7 +63,7 @@ template <typename InIt> * Creates a std::string from a fixed-size NUL-terminated char buffer. If the buffer isn't * NUL-terminated then the string ends at max_len characters. */ -[[nodiscard]] std::string StringFromFixedZeroTerminatedBuffer(const char* buffer, +[[nodiscard]] std::string StringFromFixedZeroTerminatedBuffer(std::string_view buffer, std::size_t max_len); /** diff --git a/src/core/arm/dynarmic/arm_dynarmic_64.cpp b/src/core/arm/dynarmic/arm_dynarmic_64.cpp index bf27ffe714..4fd15f1112 100644 --- a/src/core/arm/dynarmic/arm_dynarmic_64.cpp +++ b/src/core/arm/dynarmic/arm_dynarmic_64.cpp @@ -263,7 +263,7 @@ void ARM_Dynarmic_64::Run() { } void ARM_Dynarmic_64::Step() { - cb->InterpreterFallback(jit->GetPC(), 1); + jit->Step(); } ARM_Dynarmic_64::ARM_Dynarmic_64(System& system_, CPUInterrupts& interrupt_handlers_, diff --git a/src/core/core.cpp b/src/core/core.cpp index bb268a3197..3c75f42ae9 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -139,27 +139,47 @@ struct System::Impl { : kernel{system}, fs_controller{system}, memory{system}, cpu_manager{system}, reporter{system}, applet_manager{system}, time_manager{system} {} - ResultStatus Run() { - status = ResultStatus::Success; + SystemResultStatus Run() { + std::unique_lock<std::mutex> lk(suspend_guard); + status = SystemResultStatus::Success; kernel.Suspend(false); core_timing.SyncPause(false); cpu_manager.Pause(false); + is_paused = false; return status; } - ResultStatus Pause() { - status = ResultStatus::Success; + SystemResultStatus Pause() { + std::unique_lock<std::mutex> lk(suspend_guard); + status = SystemResultStatus::Success; core_timing.SyncPause(true); kernel.Suspend(true); cpu_manager.Pause(true); + is_paused = true; return status; } - ResultStatus Init(System& system, Frontend::EmuWindow& emu_window) { + std::unique_lock<std::mutex> StallCPU() { + std::unique_lock<std::mutex> lk(suspend_guard); + kernel.Suspend(true); + core_timing.SyncPause(true); + cpu_manager.Pause(true); + return lk; + } + + void UnstallCPU() { + if (!is_paused) { + core_timing.SyncPause(false); + kernel.Suspend(false); + cpu_manager.Pause(false); + } + } + + SystemResultStatus Init(System& system, Frontend::EmuWindow& emu_window) { LOG_DEBUG(Core, "initialized OK"); device_memory = std::make_unique<Core::DeviceMemory>(); @@ -176,8 +196,9 @@ struct System::Impl { cpu_manager.Initialize(); core_timing.Initialize([&system]() { system.RegisterHostThread(); }); - const auto current_time = std::chrono::duration_cast<std::chrono::seconds>( - std::chrono::system_clock::now().time_since_epoch()); + const auto posix_time = std::chrono::system_clock::now().time_since_epoch(); + const auto current_time = + std::chrono::duration_cast<std::chrono::seconds>(posix_time).count(); Settings::values.custom_rtc_differential = Settings::values.custom_rtc.value_or(current_time) - current_time; @@ -197,7 +218,7 @@ struct System::Impl { gpu_core = VideoCore::CreateGPU(emu_window, system); if (!gpu_core) { - return ResultStatus::ErrorVideoCore; + return SystemResultStatus::ErrorVideoCore; } service_manager = std::make_shared<Service::SM::ServiceManager>(kernel); @@ -217,21 +238,22 @@ struct System::Impl { LOG_DEBUG(Core, "Initialized OK"); - return ResultStatus::Success; + return SystemResultStatus::Success; } - ResultStatus Load(System& system, Frontend::EmuWindow& emu_window, const std::string& filepath, - u64 program_id, std::size_t program_index) { + SystemResultStatus Load(System& system, Frontend::EmuWindow& emu_window, + const std::string& filepath, u64 program_id, + std::size_t program_index) { app_loader = Loader::GetLoader(system, GetGameFileFromPath(virtual_filesystem, filepath), program_id, program_index); if (!app_loader) { LOG_CRITICAL(Core, "Failed to obtain loader for {}!", filepath); - return ResultStatus::ErrorGetLoader; + return SystemResultStatus::ErrorGetLoader; } - ResultStatus init_result{Init(system, emu_window)}; - if (init_result != ResultStatus::Success) { + SystemResultStatus init_result{Init(system, emu_window)}; + if (init_result != SystemResultStatus::Success) { LOG_CRITICAL(Core, "Failed to initialize system (Error {})!", static_cast<int>(init_result)); Shutdown(); @@ -249,8 +271,8 @@ struct System::Impl { LOG_CRITICAL(Core, "Failed to load ROM (Error {})!", load_result); Shutdown(); - return static_cast<ResultStatus>(static_cast<u32>(ResultStatus::ErrorLoader) + - static_cast<u32>(load_result)); + return static_cast<SystemResultStatus>( + static_cast<u32>(SystemResultStatus::ErrorLoader) + static_cast<u32>(load_result)); } AddGlueRegistrationForProcess(*app_loader, *main_process); kernel.MakeCurrentProcess(main_process.get()); @@ -282,7 +304,7 @@ struct System::Impl { GetAndResetPerfStats(); perf_stats->BeginSystemFrame(); - status = ResultStatus::Success; + status = SystemResultStatus::Success; return status; } @@ -355,7 +377,7 @@ struct System::Impl { arp_manager.Register(launch.title_id, launch, std::move(nacp_data)); } - void SetStatus(ResultStatus new_status, const char* details = nullptr) { + void SetStatus(SystemResultStatus new_status, const char* details = nullptr) { status = new_status; if (details) { status_details = details; @@ -366,6 +388,9 @@ struct System::Impl { return perf_stats->GetAndResetStats(core_timing.GetGlobalTimeUs()); } + std::mutex suspend_guard; + bool is_paused{}; + Timing::CoreTiming core_timing; Kernel::KernelCore kernel; /// RealVfsFilesystem instance @@ -411,7 +436,7 @@ struct System::Impl { /// Network instance Network::NetworkInstance network_instance; - ResultStatus status = ResultStatus::Success; + SystemResultStatus status = SystemResultStatus::Success; std::string status_details = ""; std::unique_ptr<Core::PerfStats> perf_stats; @@ -428,21 +453,8 @@ struct System::Impl { }; System::System() : impl{std::make_unique<Impl>(*this)} {} -System::~System() = default; -System& System::GetInstance() { - if (!s_instance) { - throw std::runtime_error("Using System instance before its initialization"); - } - return *s_instance; -} - -void System::InitializeGlobalInstance() { - if (s_instance) { - throw std::runtime_error("Reinitializing Global System instance."); - } - s_instance = std::unique_ptr<System>(new System); -} +System::~System() = default; CpuManager& System::GetCpuManager() { return impl->cpu_manager; @@ -452,16 +464,16 @@ const CpuManager& System::GetCpuManager() const { return impl->cpu_manager; } -System::ResultStatus System::Run() { +SystemResultStatus System::Run() { return impl->Run(); } -System::ResultStatus System::Pause() { +SystemResultStatus System::Pause() { return impl->Pause(); } -System::ResultStatus System::SingleStep() { - return ResultStatus::Success; +SystemResultStatus System::SingleStep() { + return SystemResultStatus::Success; } void System::InvalidateCpuInstructionCaches() { @@ -476,8 +488,16 @@ void System::Shutdown() { impl->Shutdown(); } -System::ResultStatus System::Load(Frontend::EmuWindow& emu_window, const std::string& filepath, - u64 program_id, std::size_t program_index) { +std::unique_lock<std::mutex> System::StallCPU() { + return impl->StallCPU(); +} + +void System::UnstallCPU() { + impl->UnstallCPU(); +} + +SystemResultStatus System::Load(Frontend::EmuWindow& emu_window, const std::string& filepath, + u64 program_id, std::size_t program_index) { return impl->Load(*this, emu_window, filepath, program_id, program_index); } @@ -637,7 +657,7 @@ Loader::ResultStatus System::GetGameName(std::string& out) const { return impl->GetGameName(out); } -void System::SetStatus(ResultStatus new_status, const char* details) { +void System::SetStatus(SystemResultStatus new_status, const char* details) { impl->SetStatus(new_status, details); } diff --git a/src/core/core.h b/src/core/core.h index a796472b22..1cfe1bba6e 100644 --- a/src/core/core.h +++ b/src/core/core.h @@ -7,6 +7,7 @@ #include <cstddef> #include <functional> #include <memory> +#include <mutex> #include <string> #include <vector> @@ -104,55 +105,49 @@ struct PerfStatsResults; FileSys::VirtualFile GetGameFileFromPath(const FileSys::VirtualFilesystem& vfs, const std::string& path); +/// Enumeration representing the return values of the System Initialize and Load process. +enum class SystemResultStatus : u32 { + Success, ///< Succeeded + ErrorNotInitialized, ///< Error trying to use core prior to initialization + ErrorGetLoader, ///< Error finding the correct application loader + ErrorSystemFiles, ///< Error in finding system files + ErrorSharedFont, ///< Error in finding shared font + ErrorVideoCore, ///< Error in the video core + ErrorUnknown, ///< Any other error + ErrorLoader, ///< The base for loader errors (too many to repeat) +}; + class System { public: using CurrentBuildProcessID = std::array<u8, 0x20>; + explicit System(); + + ~System(); + System(const System&) = delete; System& operator=(const System&) = delete; System(System&&) = delete; System& operator=(System&&) = delete; - ~System(); - - /** - * Gets the instance of the System singleton class. - * @returns Reference to the instance of the System singleton class. - */ - [[deprecated("Use of the global system instance is deprecated")]] static System& GetInstance(); - - static void InitializeGlobalInstance(); - - /// Enumeration representing the return values of the System Initialize and Load process. - enum class ResultStatus : u32 { - Success, ///< Succeeded - ErrorNotInitialized, ///< Error trying to use core prior to initialization - ErrorGetLoader, ///< Error finding the correct application loader - ErrorSystemFiles, ///< Error in finding system files - ErrorSharedFont, ///< Error in finding shared font - ErrorVideoCore, ///< Error in the video core - ErrorUnknown, ///< Any other error - ErrorLoader, ///< The base for loader errors (too many to repeat) - }; - /** * Run the OS and Application * This function will start emulation and run the relevant devices */ - [[nodiscard]] ResultStatus Run(); + [[nodiscard]] SystemResultStatus Run(); /** * Pause the OS and Application * This function will pause emulation and stop the relevant devices */ - [[nodiscard]] ResultStatus Pause(); + [[nodiscard]] SystemResultStatus Pause(); /** * Step the CPU one instruction * @return Result status, indicating whether or not the operation succeeded. */ - [[nodiscard]] ResultStatus SingleStep(); + [[nodiscard]] SystemResultStatus SingleStep(); /** * Invalidate the CPU instruction caches @@ -166,16 +161,20 @@ public: /// Shutdown the emulated system. void Shutdown(); + std::unique_lock<std::mutex> StallCPU(); + void UnstallCPU(); + /** * Load an executable application. * @param emu_window Reference to the host-system window used for video output and keyboard * input. * @param filepath String path to the executable application to load on the host file system. * @param program_index Specifies the index within the container of the program to launch. - * @returns ResultStatus code, indicating if the operation succeeded. + * @returns SystemResultStatus code, indicating if the operation succeeded. */ - [[nodiscard]] ResultStatus Load(Frontend::EmuWindow& emu_window, const std::string& filepath, - u64 program_id = 0, std::size_t program_index = 0); + [[nodiscard]] SystemResultStatus Load(Frontend::EmuWindow& emu_window, + const std::string& filepath, u64 program_id = 0, + std::size_t program_index = 0); /** * Indicates if the emulated system is powered on (all subsystems initialized and able to run an @@ -301,7 +300,7 @@ public: /// Gets the name of the current game [[nodiscard]] Loader::ResultStatus GetGameName(std::string& out) const; - void SetStatus(ResultStatus new_status, const char* details); + void SetStatus(SystemResultStatus new_status, const char* details); [[nodiscard]] const std::string& GetStatusDetails() const; @@ -403,12 +402,8 @@ public: void ApplySettings(); private: - System(); - struct Impl; std::unique_ptr<Impl> impl; - - inline static std::unique_ptr<System> s_instance{}; }; } // namespace Core diff --git a/src/core/hle/kernel/k_page_table.cpp b/src/core/hle/kernel/k_page_table.cpp index 7012685455..5e0b620c27 100644 --- a/src/core/hle/kernel/k_page_table.cpp +++ b/src/core/hle/kernel/k_page_table.cpp @@ -363,6 +363,8 @@ ResultCode KPageTable::UnmapProcessCodeMemory(VAddr dst_addr, VAddr src_addr, st block_manager->Update(src_addr, num_pages, KMemoryState::Normal, KMemoryPermission::ReadAndWrite); + system.InvalidateCpuInstructionCacheRange(dst_addr, size); + return ResultSuccess; } diff --git a/src/core/hle/kernel/k_scheduler.h b/src/core/hle/kernel/k_scheduler.h index c8ccc1ae43..7df2884383 100644 --- a/src/core/hle/kernel/k_scheduler.h +++ b/src/core/hle/kernel/k_scheduler.h @@ -49,6 +49,11 @@ public: /// Gets the current running thread [[nodiscard]] KThread* GetCurrentThread() const; + /// Gets the idle thread + [[nodiscard]] KThread* GetIdleThread() const { + return idle_thread; + } + /// Returns true if the scheduler is idle [[nodiscard]] bool IsIdle() const { return GetCurrentThread() == idle_thread; diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index f98f24a608..7f38ade1c0 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp @@ -886,7 +886,24 @@ static ResultCode GetInfo(Core::System& system, u64* result, u64 info_id, Handle *result = out_ticks; return ResultSuccess; } + case GetInfoType::IdleTickCount: { + if (handle == 0) { + LOG_ERROR(Kernel_SVC, "Thread handle does not exist, handle=0x{:08X}", + static_cast<Handle>(handle)); + return ResultInvalidHandle; + } + if (info_sub_id != 0xFFFFFFFFFFFFFFFF && info_sub_id != system.CurrentCoreIndex()) { + LOG_ERROR(Kernel_SVC, "Core is not the current core, got {}", info_sub_id); + return ResultInvalidCombination; + } + + const auto& scheduler = *system.Kernel().CurrentScheduler(); + const auto* const idle_thread = scheduler.GetIdleThread(); + + *result = idle_thread->GetCpuTime(); + return ResultSuccess; + } default: LOG_ERROR(Kernel_SVC, "Unimplemented svcGetInfo id=0x{:016X}", info_id); return ResultInvalidEnumValue; diff --git a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp index 8b4867ca73..f9b82b5047 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp @@ -92,6 +92,7 @@ NvResult nvhost_ctrl::IocCtrlEventWait(const std::vector<u8>& input, std::vector if (syncpoint_manager.IsSyncpointExpired(params.syncpt_id, params.threshold)) { params.value = syncpoint_manager.GetSyncpointMin(params.syncpt_id); std::memcpy(output.data(), ¶ms, sizeof(params)); + events_interface.failed[event_id] = false; return NvResult::Success; } @@ -99,6 +100,7 @@ NvResult nvhost_ctrl::IocCtrlEventWait(const std::vector<u8>& input, std::vector syncpoint_manager.IsSyncpointExpired(params.syncpt_id, params.threshold)) { params.value = new_value; std::memcpy(output.data(), ¶ms, sizeof(params)); + events_interface.failed[event_id] = false; return NvResult::Success; } @@ -117,6 +119,7 @@ NvResult nvhost_ctrl::IocCtrlEventWait(const std::vector<u8>& input, std::vector event.event->GetWritableEvent().Signal(); params.value = current_syncpoint_value; std::memcpy(output.data(), ¶ms, sizeof(params)); + events_interface.failed[event_id] = false; return NvResult::Success; } const u32 target_value = current_syncpoint_value - diff; @@ -146,6 +149,16 @@ NvResult nvhost_ctrl::IocCtrlEventWait(const std::vector<u8>& input, std::vector } params.value |= event_id; event.event->GetWritableEvent().Clear(); + if (events_interface.failed[event_id]) { + { + auto lk = system.StallCPU(); + gpu.WaitFence(params.syncpt_id, target_value); + system.UnstallCPU(); + } + std::memcpy(output.data(), ¶ms, sizeof(params)); + events_interface.failed[event_id] = false; + return NvResult::Success; + } gpu.RegisterSyncptInterrupt(params.syncpt_id, target_value); std::memcpy(output.data(), ¶ms, sizeof(params)); return NvResult::Timeout; @@ -201,6 +214,7 @@ NvResult nvhost_ctrl::IocCtrlClearEventWait(const std::vector<u8>& input, std::v if (events_interface.status[event_id] == EventState::Waiting) { events_interface.LiberateEvent(event_id); } + events_interface.failed[event_id] = true; syncpoint_manager.RefreshSyncpoint(events_interface.events[event_id].fence.id); diff --git a/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.cpp b/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.cpp index 845de724d1..e61261f983 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.cpp @@ -69,8 +69,7 @@ NvResult nvhost_nvdec_common::Submit(const std::vector<u8>& input, std::vector<u std::vector<Reloc> relocs(params.relocation_count); std::vector<u32> reloc_shifts(params.relocation_count); std::vector<SyncptIncr> syncpt_increments(params.syncpoint_count); - std::vector<SyncptIncr> wait_checks(params.syncpoint_count); - std::vector<Fence> fences(params.fence_count); + std::vector<u32> fence_thresholds(params.fence_count); // Slice input into their respective buffers std::size_t offset = sizeof(IoctlSubmit); @@ -78,15 +77,13 @@ NvResult nvhost_nvdec_common::Submit(const std::vector<u8>& input, std::vector<u offset += SliceVectors(input, relocs, params.relocation_count, offset); offset += SliceVectors(input, reloc_shifts, params.relocation_count, offset); offset += SliceVectors(input, syncpt_increments, params.syncpoint_count, offset); - offset += SliceVectors(input, wait_checks, params.syncpoint_count, offset); - offset += SliceVectors(input, fences, params.fence_count, offset); + offset += SliceVectors(input, fence_thresholds, params.fence_count, offset); auto& gpu = system.GPU(); if (gpu.UseNvdec()) { for (std::size_t i = 0; i < syncpt_increments.size(); i++) { const SyncptIncr& syncpt_incr = syncpt_increments[i]; - fences[i].id = syncpt_incr.id; - fences[i].value = + fence_thresholds[i] = syncpoint_manager.IncreaseSyncpoint(syncpt_incr.id, syncpt_incr.increments); } } @@ -98,11 +95,6 @@ NvResult nvhost_nvdec_common::Submit(const std::vector<u8>& input, std::vector<u cmdlist.size() * sizeof(u32)); gpu.PushCommandBuffer(cmdlist); } - if (gpu.UseNvdec()) { - fences[0].value = syncpoint_manager.IncreaseSyncpoint(fences[0].id, 1); - Tegra::ChCommandHeaderList cmdlist{{(4 << 28) | fences[0].id}}; - gpu.PushCommandBuffer(cmdlist); - } std::memcpy(output.data(), ¶ms, sizeof(IoctlSubmit)); // Some games expect command_buffers to be written back offset = sizeof(IoctlSubmit); @@ -110,8 +102,7 @@ NvResult nvhost_nvdec_common::Submit(const std::vector<u8>& input, std::vector<u offset += WriteVectors(output, relocs, offset); offset += WriteVectors(output, reloc_shifts, offset); offset += WriteVectors(output, syncpt_increments, offset); - offset += WriteVectors(output, wait_checks, offset); - offset += WriteVectors(output, fences, offset); + offset += WriteVectors(output, fence_thresholds, offset); return NvResult::Success; } diff --git a/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.h b/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.h index af59f00d2a..ae4199b79e 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.h +++ b/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.h @@ -56,19 +56,16 @@ protected: s32 target{}; s32 target_offset{}; }; - static_assert(sizeof(Reloc) == 0x10, "CommandBuffer has incorrect size"); + static_assert(sizeof(Reloc) == 0x10, "Reloc has incorrect size"); struct SyncptIncr { u32 id{}; u32 increments{}; + u32 unk0{}; + u32 unk1{}; + u32 unk2{}; }; - static_assert(sizeof(SyncptIncr) == 0x8, "CommandBuffer has incorrect size"); - - struct Fence { - u32 id{}; - u32 value{}; - }; - static_assert(sizeof(Fence) == 0x8, "CommandBuffer has incorrect size"); + static_assert(sizeof(SyncptIncr) == 0x14, "SyncptIncr has incorrect size"); struct IoctlGetSyncpoint { // Input diff --git a/src/core/hle/service/nvdrv/nvdrv.h b/src/core/hle/service/nvdrv/nvdrv.h index e2a1dde5b6..a5af5b7850 100644 --- a/src/core/hle/service/nvdrv/nvdrv.h +++ b/src/core/hle/service/nvdrv/nvdrv.h @@ -49,6 +49,8 @@ struct EventInterface { std::array<EventState, MaxNvEvents> status{}; // Tells if an NVEvent is registered or not std::array<bool, MaxNvEvents> registered{}; + // Tells the NVEvent that it has failed. + std::array<bool, MaxNvEvents> failed{}; // When an NVEvent is waiting on GPU interrupt, this is the sync_point // associated with it. std::array<u32, MaxNvEvents> assigned_syncpt{}; diff --git a/src/core/hle/service/time/time_manager.cpp b/src/core/hle/service/time/time_manager.cpp index 4bbc606a16..9c4c960ef4 100644 --- a/src/core/hle/service/time/time_manager.cpp +++ b/src/core/hle/service/time/time_manager.cpp @@ -13,18 +13,19 @@ #include "core/hle/service/time/time_manager.h" namespace Service::Time { - +namespace { constexpr Clock::TimeSpanType standard_network_clock_accuracy{0x0009356907420000ULL}; -static std::chrono::seconds GetSecondsSinceEpoch() { - return std::chrono::duration_cast<std::chrono::seconds>( - std::chrono::system_clock::now().time_since_epoch()) + +s64 GetSecondsSinceEpoch() { + const auto time_since_epoch = std::chrono::system_clock::now().time_since_epoch(); + return std::chrono::duration_cast<std::chrono::seconds>(time_since_epoch).count() + Settings::values.custom_rtc_differential; } -static s64 GetExternalRtcValue() { - return GetSecondsSinceEpoch().count() + TimeManager::GetExternalTimeZoneOffset(); +s64 GetExternalRtcValue() { + return GetSecondsSinceEpoch() + TimeManager::GetExternalTimeZoneOffset(); } +} // Anonymous namespace struct TimeManager::Impl final { explicit Impl(Core::System& system) diff --git a/src/core/hle/service/vi/vi.cpp b/src/core/hle/service/vi/vi.cpp index be3d52d543..439e7e4726 100644 --- a/src/core/hle/service/vi/vi.cpp +++ b/src/core/hle/service/vi/vi.cpp @@ -524,7 +524,9 @@ private: Disconnect = 11, AllocateBuffers = 13, - SetPreallocatedBuffer = 14 + SetPreallocatedBuffer = 14, + + GetBufferHistory = 17 }; void TransactParcel(Kernel::HLERequestContext& ctx) { @@ -641,6 +643,14 @@ private: ctx.WriteBuffer(response.Serialize()); break; } + case TransactionId::GetBufferHistory: { + LOG_WARNING(Service_VI, "(STUBBED) called, transaction=GetBufferHistory"); + [[maybe_unused]] const auto buffer = ctx.ReadBuffer(); + + IGBPEmptyResponseParcel response{}; + ctx.WriteBuffer(response.Serialize()); + break; + } default: ASSERT_MSG(false, "Unimplemented"); } diff --git a/src/input_common/udp/client.cpp b/src/input_common/udp/client.cpp index 9b0aec7970..b9512aa2e9 100644 --- a/src/input_common/udp/client.cpp +++ b/src/input_common/udp/client.cpp @@ -471,46 +471,42 @@ CalibrationConfigurationJob::CalibrationConfigurationJob( std::function<void(u16, u16, u16, u16)> data_callback) { std::thread([=, this] { - constexpr u16 CALIBRATION_THRESHOLD = 100; - - u16 min_x{UINT16_MAX}; - u16 min_y{UINT16_MAX}; - u16 max_x{}; - u16 max_y{}; - Status current_status{Status::Initialized}; - SocketCallback callback{[](Response::Version) {}, [](Response::PortInfo) {}, - [&](Response::PadData data) { - if (current_status == Status::Initialized) { - // Receiving data means the communication is ready now - current_status = Status::Ready; - status_callback(current_status); - } - if (data.touch[0].is_active == 0) { - return; - } - LOG_DEBUG(Input, "Current touch: {} {}", data.touch[0].x, - data.touch[0].y); - min_x = std::min(min_x, static_cast<u16>(data.touch[0].x)); - min_y = std::min(min_y, static_cast<u16>(data.touch[0].y)); - if (current_status == Status::Ready) { - // First touch - min data (min_x/min_y) - current_status = Status::Stage1Completed; - status_callback(current_status); - } - if (data.touch[0].x - min_x > CALIBRATION_THRESHOLD && - data.touch[0].y - min_y > CALIBRATION_THRESHOLD) { - // Set the current position as max value and finishes - // configuration - max_x = data.touch[0].x; - max_y = data.touch[0].y; - current_status = Status::Completed; - data_callback(min_x, min_y, max_x, max_y); - status_callback(current_status); - - complete_event.Set(); - } - }}; + SocketCallback callback{ + [](Response::Version) {}, [](Response::PortInfo) {}, + [&](Response::PadData data) { + static constexpr u16 CALIBRATION_THRESHOLD = 100; + static constexpr u16 MAX_VALUE = UINT16_MAX; + + if (current_status == Status::Initialized) { + // Receiving data means the communication is ready now + current_status = Status::Ready; + status_callback(current_status); + } + const auto& touchpad_0 = data.touch[0]; + if (touchpad_0.is_active == 0) { + return; + } + LOG_DEBUG(Input, "Current touch: {} {}", touchpad_0.x, touchpad_0.y); + const u16 min_x = std::min(MAX_VALUE, static_cast<u16>(touchpad_0.x)); + const u16 min_y = std::min(MAX_VALUE, static_cast<u16>(touchpad_0.y)); + if (current_status == Status::Ready) { + // First touch - min data (min_x/min_y) + current_status = Status::Stage1Completed; + status_callback(current_status); + } + if (touchpad_0.x - min_x > CALIBRATION_THRESHOLD && + touchpad_0.y - min_y > CALIBRATION_THRESHOLD) { + // Set the current position as max value and finishes configuration + const u16 max_x = touchpad_0.x; + const u16 max_y = touchpad_0.y; + current_status = Status::Completed; + data_callback(min_x, min_y, max_x, max_y); + status_callback(current_status); + + complete_event.Set(); + } + }}; Socket socket{host, port, std::move(callback)}; std::thread worker_thread{SocketLoop, &socket}; complete_event.Wait(); diff --git a/src/shader_recompiler/ir_opt/texture_pass.cpp b/src/shader_recompiler/ir_opt/texture_pass.cpp index 44ad10d43f..96c997a580 100644 --- a/src/shader_recompiler/ir_opt/texture_pass.cpp +++ b/src/shader_recompiler/ir_opt/texture_pass.cpp @@ -492,7 +492,8 @@ void TexturePass(Environment& env, IR::Program& program) { const auto insert_point{IR::Block::InstructionList::s_iterator_to(*inst)}; IR::IREmitter ir{*texture_inst.block, insert_point}; const IR::U32 shift{ir.Imm32(std::countr_zero(DESCRIPTOR_SIZE))}; - inst->SetArg(0, ir.ShiftRightArithmetic(cbuf.dynamic_offset, shift)); + inst->SetArg(0, ir.UMin(ir.ShiftRightArithmetic(cbuf.dynamic_offset, shift), + ir.Imm32(DESCRIPTOR_SIZE - 1))); } else { inst->SetArg(0, IR::Value{}); } diff --git a/src/video_core/dirty_flags.h b/src/video_core/dirty_flags.h index 504465d3fb..f0d545f905 100644 --- a/src/video_core/dirty_flags.h +++ b/src/video_core/dirty_flags.h @@ -38,6 +38,9 @@ enum : u8 { Shaders, + // Special entries + DepthBiasGlobal, + LastCommonEntry, }; diff --git a/src/video_core/query_cache.h b/src/video_core/query_cache.h index 73231061a3..392f82eb79 100644 --- a/src/video_core/query_cache.h +++ b/src/video_core/query_cache.h @@ -258,9 +258,9 @@ private: void AsyncFlushQuery(VAddr addr) { if (!uncommitted_flushes) { - uncommitted_flushes = std::make_shared<std::unordered_set<VAddr>>(); + uncommitted_flushes = std::make_shared<std::vector<VAddr>>(); } - uncommitted_flushes->insert(addr); + uncommitted_flushes->push_back(addr); } static constexpr std::uintptr_t PAGE_SIZE = 4096; @@ -276,8 +276,8 @@ private: std::array<CounterStream, VideoCore::NumQueryTypes> streams; - std::shared_ptr<std::unordered_set<VAddr>> uncommitted_flushes{}; - std::list<std::shared_ptr<std::unordered_set<VAddr>>> committed_flushes; + std::shared_ptr<std::vector<VAddr>> uncommitted_flushes{}; + std::list<std::shared_ptr<std::vector<VAddr>>> committed_flushes; }; template <class QueryCache, class HostCounter> diff --git a/src/video_core/rasterizer_accelerated.h b/src/video_core/rasterizer_accelerated.h index ea879bfddb..249644e506 100644 --- a/src/video_core/rasterizer_accelerated.h +++ b/src/video_core/rasterizer_accelerated.h @@ -42,7 +42,7 @@ private: }; static_assert(sizeof(CacheEntry) == 8, "CacheEntry should be 8 bytes!"); - std::array<CacheEntry, 0x1000000> cached_pages; + std::array<CacheEntry, 0x2000000> cached_pages; Core::Memory::Memory& cpu_memory; }; diff --git a/src/video_core/renderer_opengl/gl_device.cpp b/src/video_core/renderer_opengl/gl_device.cpp index 9692b8e946..1e1d1d0209 100644 --- a/src/video_core/renderer_opengl/gl_device.cpp +++ b/src/video_core/renderer_opengl/gl_device.cpp @@ -10,6 +10,7 @@ #include <limits> #include <optional> #include <span> +#include <stdexcept> #include <vector> #include <glad/glad.h> diff --git a/src/video_core/renderer_vulkan/vk_master_semaphore.h b/src/video_core/renderer_vulkan/vk_master_semaphore.h index 4f86881183..0886b7da81 100644 --- a/src/video_core/renderer_vulkan/vk_master_semaphore.h +++ b/src/video_core/renderer_vulkan/vk_master_semaphore.h @@ -21,12 +21,12 @@ public: /// Returns the current logical tick. [[nodiscard]] u64 CurrentTick() const noexcept { - return current_tick.load(std::memory_order_relaxed); + return current_tick.load(std::memory_order_acquire); } /// Returns the last known GPU tick. [[nodiscard]] u64 KnownGpuTick() const noexcept { - return gpu_tick.load(std::memory_order_relaxed); + return gpu_tick.load(std::memory_order_acquire); } /// Returns the timeline semaphore handle. @@ -41,12 +41,21 @@ public: /// Advance to the logical tick and return the old one [[nodiscard]] u64 NextTick() noexcept { - return current_tick.fetch_add(1, std::memory_order::relaxed); + return current_tick.fetch_add(1, std::memory_order_release); } /// Refresh the known GPU tick void Refresh() { - gpu_tick.store(semaphore.GetCounter(), std::memory_order_relaxed); + u64 this_tick{}; + u64 counter{}; + do { + this_tick = gpu_tick.load(std::memory_order_acquire); + counter = semaphore.GetCounter(); + if (counter < this_tick) { + return; + } + } while (!gpu_tick.compare_exchange_weak(this_tick, counter, std::memory_order_release, + std::memory_order_relaxed)); } /// Waits for a tick to be hit on the GPU diff --git a/src/video_core/renderer_vulkan/vk_query_cache.cpp b/src/video_core/renderer_vulkan/vk_query_cache.cpp index c9cb32d713..259cba156b 100644 --- a/src/video_core/renderer_vulkan/vk_query_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_query_cache.cpp @@ -117,7 +117,8 @@ u64 HostCounter::BlockingQuery() const { cache.GetScheduler().Wait(tick); u64 data; const VkResult query_result = cache.GetDevice().GetLogical().GetQueryResults( - query.first, query.second, 1, sizeof(data), &data, sizeof(data), VK_QUERY_RESULT_64_BIT); + query.first, query.second, 1, sizeof(data), &data, sizeof(data), + VK_QUERY_RESULT_64_BIT | VK_QUERY_RESULT_WAIT_BIT); switch (query_result) { case VK_SUCCESS: diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.cpp b/src/video_core/renderer_vulkan/vk_rasterizer.cpp index 3bcd6d6cc6..30b47a7a0f 100644 --- a/src/video_core/renderer_vulkan/vk_rasterizer.cpp +++ b/src/video_core/renderer_vulkan/vk_rasterizer.cpp @@ -627,9 +627,21 @@ void RasterizerVulkan::UpdateDepthBias(Tegra::Engines::Maxwell3D::Regs& regs) { if (!state_tracker.TouchDepthBias()) { return; } - scheduler.Record([constant = regs.polygon_offset_units, clamp = regs.polygon_offset_clamp, + float units = regs.polygon_offset_units / 2.0f; + const bool is_d24 = regs.zeta.format == Tegra::DepthFormat::S8_UINT_Z24_UNORM || + regs.zeta.format == Tegra::DepthFormat::D24X8_UNORM || + regs.zeta.format == Tegra::DepthFormat::D24S8_UNORM || + regs.zeta.format == Tegra::DepthFormat::D24C8_UNORM; + if (is_d24 && !device.SupportsD24DepthBuffer()) { + // the base formulas can be obtained from here: + // https://docs.microsoft.com/en-us/windows/win32/direct3d11/d3d10-graphics-programming-guide-output-merger-stage-depth-bias + const double rescale_factor = + static_cast<double>(1ULL << (32 - 24)) / (static_cast<double>(0x1.ep+127)); + units = static_cast<float>(static_cast<double>(units) * rescale_factor); + } + scheduler.Record([constant = units, clamp = regs.polygon_offset_clamp, factor = regs.polygon_offset_factor](vk::CommandBuffer cmdbuf) { - cmdbuf.SetDepthBias(constant, clamp, factor / 2.0f); + cmdbuf.SetDepthBias(constant, clamp, factor); }); } diff --git a/src/video_core/renderer_vulkan/vk_state_tracker.cpp b/src/video_core/renderer_vulkan/vk_state_tracker.cpp index e3b7dd61cb..c00913f558 100644 --- a/src/video_core/renderer_vulkan/vk_state_tracker.cpp +++ b/src/video_core/renderer_vulkan/vk_state_tracker.cpp @@ -54,6 +54,7 @@ void SetupDirtyViewports(Tables& tables) { FillBlock(tables[0], OFF(viewport_transform), NUM(viewport_transform), Viewports); FillBlock(tables[0], OFF(viewports), NUM(viewports), Viewports); tables[0][OFF(viewport_transform_enabled)] = Viewports; + tables[1][OFF(screen_y_control)] = Viewports; } void SetupDirtyScissors(Tables& tables) { diff --git a/src/video_core/renderer_vulkan/vk_state_tracker.h b/src/video_core/renderer_vulkan/vk_state_tracker.h index d90935f528..2f2d6b31f0 100644 --- a/src/video_core/renderer_vulkan/vk_state_tracker.h +++ b/src/video_core/renderer_vulkan/vk_state_tracker.h @@ -79,7 +79,8 @@ public: } bool TouchDepthBias() { - return Exchange(Dirty::DepthBias, false); + return Exchange(Dirty::DepthBias, false) || + Exchange(VideoCommon::Dirty::DepthBiasGlobal, false); } bool TouchBlendConstants() { diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h index 329df2e495..f70c1f764a 100644 --- a/src/video_core/texture_cache/texture_cache.h +++ b/src/video_core/texture_cache/texture_cache.h @@ -221,6 +221,7 @@ void TextureCache<P>::UpdateRenderTargets(bool is_clear) { BindRenderTarget(&render_targets.depth_buffer_id, FindDepthBuffer(is_clear)); } const ImageViewId depth_buffer_id = render_targets.depth_buffer_id; + PrepareImageView(depth_buffer_id, true, is_clear && IsFullClear(depth_buffer_id)); for (size_t index = 0; index < NUM_RT; ++index) { @@ -230,6 +231,8 @@ void TextureCache<P>::UpdateRenderTargets(bool is_clear) { maxwell3d.regs.render_area.width, maxwell3d.regs.render_area.height, }; + + flags[Dirty::DepthBiasGlobal] = true; } template <class P> diff --git a/src/video_core/vulkan_common/vulkan_device.cpp b/src/video_core/vulkan_common/vulkan_device.cpp index 6388ed2eb1..0f807990ca 100644 --- a/src/video_core/vulkan_common/vulkan_device.cpp +++ b/src/video_core/vulkan_common/vulkan_device.cpp @@ -623,6 +623,10 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR is_float16_supported = false; } + supports_d24_depth = + IsFormatSupported(VK_FORMAT_D24_UNORM_S8_UINT, + VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT, FormatType::Optimal); + graphics_queue = logical.GetQueue(graphics_family); present_queue = logical.GetQueue(present_family); } diff --git a/src/video_core/vulkan_common/vulkan_device.h b/src/video_core/vulkan_common/vulkan_device.h index d9e74f1aac..2d5daf6cd2 100644 --- a/src/video_core/vulkan_common/vulkan_device.h +++ b/src/video_core/vulkan_common/vulkan_device.h @@ -332,6 +332,10 @@ public: return sets_per_pool; } + bool SupportsD24DepthBuffer() const { + return supports_d24_depth; + } + private: /// Checks if the physical device is suitable. void CheckSuitability(bool requires_swapchain) const; @@ -425,6 +429,7 @@ private: bool has_broken_cube_compatibility{}; ///< Has broken cube compatiblity bit bool has_renderdoc{}; ///< Has RenderDoc attached bool has_nsight_graphics{}; ///< Has Nsight Graphics attached + bool supports_d24_depth{}; ///< Supports D24 depth buffers. // Telemetry parameters std::string vendor_name; ///< Device's driver name. diff --git a/src/yuzu/about_dialog.cpp b/src/yuzu/about_dialog.cpp index 6b0155a788..04ab4ae21c 100644 --- a/src/yuzu/about_dialog.cpp +++ b/src/yuzu/about_dialog.cpp @@ -8,7 +8,8 @@ #include "ui_aboutdialog.h" #include "yuzu/about_dialog.h" -AboutDialog::AboutDialog(QWidget* parent) : QDialog(parent), ui(new Ui::AboutDialog) { +AboutDialog::AboutDialog(QWidget* parent) + : QDialog(parent), ui{std::make_unique<Ui::AboutDialog>()} { const auto branch_name = std::string(Common::g_scm_branch); const auto description = std::string(Common::g_scm_desc); const auto build_id = std::string(Common::g_build_id); diff --git a/src/yuzu/applets/qt_web_browser.cpp b/src/yuzu/applets/qt_web_browser.cpp index 7d433ca503..da8c6882ab 100644 --- a/src/yuzu/applets/qt_web_browser.cpp +++ b/src/yuzu/applets/qt_web_browser.cpp @@ -3,6 +3,7 @@ // Refer to the license.txt file included. #ifdef YUZU_USE_QT_WEB_ENGINE +#include <QApplication> #include <QKeyEvent> #include <QWebEngineProfile> diff --git a/src/yuzu/bootmanager.cpp b/src/yuzu/bootmanager.cpp index c75f5e1ee1..40fd474063 100644 --- a/src/yuzu/bootmanager.cpp +++ b/src/yuzu/bootmanager.cpp @@ -86,15 +86,15 @@ void EmuThread::run() { } running_guard = true; - Core::System::ResultStatus result = system.Run(); - if (result != Core::System::ResultStatus::Success) { + Core::SystemResultStatus result = system.Run(); + if (result != Core::SystemResultStatus::Success) { running_guard = false; this->SetRunning(false); emit ErrorThrown(result, system.GetStatusDetails()); } running_wait.Wait(); result = system.Pause(); - if (result != Core::System::ResultStatus::Success) { + if (result != Core::SystemResultStatus::Success) { running_guard = false; this->SetRunning(false); emit ErrorThrown(result, system.GetStatusDetails()); diff --git a/src/yuzu/bootmanager.h b/src/yuzu/bootmanager.h index 8d7ab8c2e9..e6a0666e9a 100644 --- a/src/yuzu/bootmanager.h +++ b/src/yuzu/bootmanager.h @@ -16,7 +16,6 @@ #include <QWindow> #include "common/thread.h" -#include "core/core.h" #include "core/frontend/emu_window.h" class GRenderWindow; @@ -24,6 +23,11 @@ class GMainWindow; class QKeyEvent; class QStringList; +namespace Core { +enum class SystemResultStatus : u32; +class System; +} // namespace Core + namespace InputCommon { class InputSubsystem; } @@ -123,7 +127,7 @@ signals: */ void DebugModeLeft(); - void ErrorThrown(Core::System::ResultStatus, std::string); + void ErrorThrown(Core::SystemResultStatus, std::string); void LoadProgress(VideoCore::LoadCallbackStage stage, std::size_t value, std::size_t total); }; diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp index 30a8641354..faea5dda11 100644 --- a/src/yuzu/configuration/config.cpp +++ b/src/yuzu/configuration/config.cpp @@ -918,8 +918,7 @@ void Config::ReadSystemValues() { const auto custom_rtc_enabled = ReadSetting(QStringLiteral("custom_rtc_enabled"), false).toBool(); if (custom_rtc_enabled) { - Settings::values.custom_rtc = - std::chrono::seconds(ReadSetting(QStringLiteral("custom_rtc"), 0).toULongLong()); + Settings::values.custom_rtc = ReadSetting(QStringLiteral("custom_rtc"), 0).toLongLong(); } else { Settings::values.custom_rtc = std::nullopt; } @@ -1450,9 +1449,7 @@ void Config::SaveSystemValues() { WriteSetting(QStringLiteral("custom_rtc_enabled"), Settings::values.custom_rtc.has_value(), false); WriteSetting(QStringLiteral("custom_rtc"), - QVariant::fromValue<long long>( - Settings::values.custom_rtc.value_or(std::chrono::seconds{}).count()), - 0); + QVariant::fromValue<long long>(Settings::values.custom_rtc.value_or(0)), 0); } WriteGlobalSetting(Settings::values.sound_index); diff --git a/src/yuzu/configuration/configure_cpu.cpp b/src/yuzu/configuration/configure_cpu.cpp index 27fabef386..f66cab5d45 100644 --- a/src/yuzu/configuration/configure_cpu.cpp +++ b/src/yuzu/configuration/configure_cpu.cpp @@ -14,7 +14,7 @@ #include "yuzu/configuration/configure_cpu.h" ConfigureCpu::ConfigureCpu(const Core::System& system_, QWidget* parent) - : QWidget(parent), ui(new Ui::ConfigureCpu), system{system_} { + : QWidget(parent), ui{std::make_unique<Ui::ConfigureCpu>()}, system{system_} { ui->setupUi(this); SetupPerGameUI(); diff --git a/src/yuzu/configuration/configure_cpu_debug.cpp b/src/yuzu/configuration/configure_cpu_debug.cpp index 6e910e33e2..05a90963df 100644 --- a/src/yuzu/configuration/configure_cpu_debug.cpp +++ b/src/yuzu/configuration/configure_cpu_debug.cpp @@ -12,7 +12,7 @@ #include "yuzu/configuration/configure_cpu_debug.h" ConfigureCpuDebug::ConfigureCpuDebug(const Core::System& system_, QWidget* parent) - : QWidget(parent), ui(new Ui::ConfigureCpuDebug), system{system_} { + : QWidget(parent), ui{std::make_unique<Ui::ConfigureCpuDebug>()}, system{system_} { ui->setupUi(this); SetConfiguration(); diff --git a/src/yuzu/configuration/configure_debug.cpp b/src/yuzu/configuration/configure_debug.cpp index 40447093eb..07bfa03603 100644 --- a/src/yuzu/configuration/configure_debug.cpp +++ b/src/yuzu/configuration/configure_debug.cpp @@ -15,7 +15,7 @@ #include "yuzu/uisettings.h" ConfigureDebug::ConfigureDebug(const Core::System& system_, QWidget* parent) - : QWidget(parent), ui(new Ui::ConfigureDebug), system{system_} { + : QWidget(parent), ui{std::make_unique<Ui::ConfigureDebug>()}, system{system_} { ui->setupUi(this); SetConfiguration(); diff --git a/src/yuzu/configuration/configure_debug_tab.cpp b/src/yuzu/configuration/configure_debug_tab.cpp index e126eeea98..e69cca1ef1 100644 --- a/src/yuzu/configuration/configure_debug_tab.cpp +++ b/src/yuzu/configuration/configure_debug_tab.cpp @@ -9,8 +9,8 @@ #include "yuzu/configuration/configure_debug_tab.h" ConfigureDebugTab::ConfigureDebugTab(const Core::System& system_, QWidget* parent) - : QWidget(parent), - ui(new Ui::ConfigureDebugTab), debug_tab{std::make_unique<ConfigureDebug>(system_, this)}, + : QWidget(parent), ui{std::make_unique<Ui::ConfigureDebugTab>()}, + debug_tab{std::make_unique<ConfigureDebug>(system_, this)}, cpu_debug_tab{std::make_unique<ConfigureCpuDebug>(system_, this)} { ui->setupUi(this); diff --git a/src/yuzu/configuration/configure_dialog.cpp b/src/yuzu/configuration/configure_dialog.cpp index cf269f5d14..642a5f9660 100644 --- a/src/yuzu/configuration/configure_dialog.cpp +++ b/src/yuzu/configuration/configure_dialog.cpp @@ -36,7 +36,7 @@ ConfigureDialog::ConfigureDialog(QWidget* parent, HotkeyRegistry& registry, InputCommon::InputSubsystem* input_subsystem, Core::System& system_) - : QDialog(parent), ui(new Ui::ConfigureDialog), + : QDialog(parent), ui{std::make_unique<Ui::ConfigureDialog>()}, registry(registry), system{system_}, audio_tab{std::make_unique<ConfigureAudio>(system_, this)}, cpu_tab{std::make_unique<ConfigureCpu>(system_, this)}, diff --git a/src/yuzu/configuration/configure_general.cpp b/src/yuzu/configuration/configure_general.cpp index e562e89e56..7af3ea97e7 100644 --- a/src/yuzu/configuration/configure_general.cpp +++ b/src/yuzu/configuration/configure_general.cpp @@ -16,7 +16,7 @@ #include "yuzu/uisettings.h" ConfigureGeneral::ConfigureGeneral(const Core::System& system_, QWidget* parent) - : QWidget(parent), ui(new Ui::ConfigureGeneral), system{system_} { + : QWidget(parent), ui{std::make_unique<Ui::ConfigureGeneral>()}, system{system_} { ui->setupUi(this); SetupPerGameUI(); diff --git a/src/yuzu/configuration/configure_graphics.cpp b/src/yuzu/configuration/configure_graphics.cpp index be4e7997bd..8e20cc6f30 100644 --- a/src/yuzu/configuration/configure_graphics.cpp +++ b/src/yuzu/configuration/configure_graphics.cpp @@ -20,7 +20,7 @@ #include "yuzu/configuration/configure_graphics.h" ConfigureGraphics::ConfigureGraphics(const Core::System& system_, QWidget* parent) - : QWidget(parent), ui(new Ui::ConfigureGraphics), system{system_} { + : QWidget(parent), ui{std::make_unique<Ui::ConfigureGraphics>()}, system{system_} { vulkan_device = Settings::values.vulkan_device.GetValue(); RetrieveVulkanDevices(); diff --git a/src/yuzu/configuration/configure_graphics_advanced.cpp b/src/yuzu/configuration/configure_graphics_advanced.cpp index 4407e65d3f..30c5a3595b 100644 --- a/src/yuzu/configuration/configure_graphics_advanced.cpp +++ b/src/yuzu/configuration/configure_graphics_advanced.cpp @@ -9,7 +9,7 @@ #include "yuzu/configuration/configure_graphics_advanced.h" ConfigureGraphicsAdvanced::ConfigureGraphicsAdvanced(const Core::System& system_, QWidget* parent) - : QWidget(parent), ui(new Ui::ConfigureGraphicsAdvanced), system{system_} { + : QWidget(parent), ui{std::make_unique<Ui::ConfigureGraphicsAdvanced>()}, system{system_} { ui->setupUi(this); diff --git a/src/yuzu/configuration/configure_per_game_addons.cpp b/src/yuzu/configuration/configure_per_game_addons.cpp index c8de8e2ff2..65e615963d 100644 --- a/src/yuzu/configuration/configure_per_game_addons.cpp +++ b/src/yuzu/configuration/configure_per_game_addons.cpp @@ -27,7 +27,7 @@ #include "yuzu/util/util.h" ConfigurePerGameAddons::ConfigurePerGameAddons(Core::System& system_, QWidget* parent) - : QWidget(parent), ui(new Ui::ConfigurePerGameAddons), system{system_} { + : QWidget(parent), ui{std::make_unique<Ui::ConfigurePerGameAddons>()}, system{system_} { ui->setupUi(this); layout = new QVBoxLayout; diff --git a/src/yuzu/configuration/configure_profile_manager.cpp b/src/yuzu/configuration/configure_profile_manager.cpp index 9feec37ff5..99d5f4686d 100644 --- a/src/yuzu/configuration/configure_profile_manager.cpp +++ b/src/yuzu/configuration/configure_profile_manager.cpp @@ -77,7 +77,7 @@ QString GetProfileUsernameFromUser(QWidget* parent, const QString& description_t } // Anonymous namespace ConfigureProfileManager::ConfigureProfileManager(const Core::System& system_, QWidget* parent) - : QWidget(parent), ui(new Ui::ConfigureProfileManager), + : QWidget(parent), ui{std::make_unique<Ui::ConfigureProfileManager>()}, profile_manager(std::make_unique<Service::Account::ProfileManager>()), system{system_} { ui->setupUi(this); diff --git a/src/yuzu/configuration/configure_system.cpp b/src/yuzu/configuration/configure_system.cpp index 33eb059a3b..56c762d643 100644 --- a/src/yuzu/configuration/configure_system.cpp +++ b/src/yuzu/configuration/configure_system.cpp @@ -18,7 +18,7 @@ #include "yuzu/configuration/configure_system.h" ConfigureSystem::ConfigureSystem(Core::System& system_, QWidget* parent) - : QWidget(parent), ui(new Ui::ConfigureSystem), system{system_} { + : QWidget(parent), ui{std::make_unique<Ui::ConfigureSystem>()}, system{system_} { ui->setupUi(this); connect(ui->button_regenerate_console_id, &QPushButton::clicked, this, &ConfigureSystem::RefreshConsoleID); @@ -65,8 +65,7 @@ void ConfigureSystem::SetConfiguration() { QStringLiteral("%1") .arg(Settings::values.rng_seed.GetValue().value_or(0), 8, 16, QLatin1Char{'0'}) .toUpper(); - const auto rtc_time = Settings::values.custom_rtc.value_or( - std::chrono::seconds(QDateTime::currentSecsSinceEpoch())); + const auto rtc_time = Settings::values.custom_rtc.value_or(QDateTime::currentSecsSinceEpoch()); ui->rng_seed_checkbox->setChecked(Settings::values.rng_seed.GetValue().has_value()); ui->rng_seed_edit->setEnabled(Settings::values.rng_seed.GetValue().has_value() && @@ -75,7 +74,7 @@ void ConfigureSystem::SetConfiguration() { ui->custom_rtc_checkbox->setChecked(Settings::values.custom_rtc.has_value()); ui->custom_rtc_edit->setEnabled(Settings::values.custom_rtc.has_value()); - ui->custom_rtc_edit->setDateTime(QDateTime::fromSecsSinceEpoch(rtc_time.count())); + ui->custom_rtc_edit->setDateTime(QDateTime::fromSecsSinceEpoch(rtc_time)); if (Settings::IsConfiguringGlobal()) { ui->combo_language->setCurrentIndex(Settings::values.language_index.GetValue()); @@ -108,10 +107,9 @@ void ConfigureSystem::ApplyConfiguration() { // to allow in-game time to be fast forwarded if (Settings::IsConfiguringGlobal()) { if (ui->custom_rtc_checkbox->isChecked()) { - Settings::values.custom_rtc = - std::chrono::seconds(ui->custom_rtc_edit->dateTime().toSecsSinceEpoch()); + Settings::values.custom_rtc = ui->custom_rtc_edit->dateTime().toSecsSinceEpoch(); if (system.IsPoweredOn()) { - const s64 posix_time{Settings::values.custom_rtc->count() + + const s64 posix_time{*Settings::values.custom_rtc + Service::Time::TimeManager::GetExternalTimeZoneOffset()}; system.GetTimeManager().UpdateLocalSystemClockTime(posix_time); } diff --git a/src/yuzu/configuration/configure_tas.ui b/src/yuzu/configuration/configure_tas.ui index 6caa19031f..7d44895c40 100644 --- a/src/yuzu/configuration/configure_tas.ui +++ b/src/yuzu/configuration/configure_tas.ui @@ -14,14 +14,14 @@ <item row="0" column="0" colspan="4"> <widget class="QLabel" name="label_1"> <property name="text"> - <string>Reads controller input from scripts in the same format as TAS-nx scripts.<br/>For a more detailed explanation please consult the FAQ on the yuzu website.</string> + <string><html><head/><body><p>Reads controller input from scripts in the same format as TAS-nx scripts.<br/>For a more detailed explanation, please consult the <a href="https://yuzu-emu.org/help/feature/tas/"><span style=" text-decoration: underline; color:#039be5;">help page</span></a> on the yuzu website.</p></body></html></string> </property> </widget> </item> <item row="1" column="0" colspan="4"> <widget class="QLabel" name="label_2"> <property name="text"> - <string>To check which hotkeys control the playback/recording, please refer to the Hotkey settings (General -> Hotkeys).</string> + <string>To check which hotkeys control the playback/recording, please refer to the Hotkey settings (Configure -> General -> Hotkeys).</string> </property> <property name="wordWrap"> <bool>true</bool> diff --git a/src/yuzu/configuration/configure_ui.cpp b/src/yuzu/configuration/configure_ui.cpp index d01895bf2c..46e5409dba 100644 --- a/src/yuzu/configuration/configure_ui.cpp +++ b/src/yuzu/configuration/configure_ui.cpp @@ -55,7 +55,7 @@ QString GetTranslatedRowTextName(size_t index) { } // Anonymous namespace ConfigureUi::ConfigureUi(Core::System& system_, QWidget* parent) - : QWidget(parent), ui(new Ui::ConfigureUi), system{system_} { + : QWidget(parent), ui{std::make_unique<Ui::ConfigureUi>()}, system{system_} { ui->setupUi(this); InitializeLanguageComboBox(); diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 9f80a245c5..2af582fe5d 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -104,6 +104,7 @@ static FileSys::VirtualFile VfsDirectoryCreateFileWrapper(const FileSys::Virtual #include "core/telemetry_session.h" #include "input_common/main.h" #include "input_common/tas/tas_input.h" +#include "ui_main.h" #include "util/overlay_dialog.h" #include "video_core/gpu.h" #include "video_core/renderer_base.h" @@ -171,7 +172,7 @@ void GMainWindow::ShowTelemetryCallout() { "<br/><br/>Would you like to share your usage data with us?"); if (QMessageBox::question(this, tr("Telemetry"), telemetry_message) != QMessageBox::Yes) { Settings::values.enable_telemetry = false; - system.ApplySettings(); + system->ApplySettings(); } } @@ -190,16 +191,17 @@ static void RemoveCachedContents() { Common::FS::RemoveDirRecursively(offline_system_data); } -GMainWindow::GMainWindow(Core::System& system_) - : input_subsystem{std::make_shared<InputCommon::InputSubsystem>()}, system{system_}, - config{std::make_unique<Config>(system_)}, +GMainWindow::GMainWindow() + : ui{std::make_unique<Ui::MainWindow>()}, system{std::make_unique<Core::System>()}, + input_subsystem{std::make_shared<InputCommon::InputSubsystem>()}, + config{std::make_unique<Config>(*system)}, vfs{std::make_shared<FileSys::RealVfsFilesystem>()}, provider{std::make_unique<FileSys::ManualContentProvider>()} { Common::Log::Initialize(); LoadTranslation(); setAcceptDrops(true); - ui.setupUi(this); + ui->setupUi(this); statusBar()->hide(); default_theme_paths = QIcon::themeSearchPaths(); @@ -256,10 +258,10 @@ GMainWindow::GMainWindow(Core::System& system_) show(); - system.SetContentProvider(std::make_unique<FileSys::ContentProviderUnion>()); - system.RegisterContentProvider(FileSys::ContentProviderUnionSlot::FrontendManual, - provider.get()); - system.GetFileSystemController().CreateFactories(*vfs); + system->SetContentProvider(std::make_unique<FileSys::ContentProviderUnion>()); + system->RegisterContentProvider(FileSys::ContentProviderUnionSlot::FrontendManual, + provider.get()); + system->GetFileSystemController().CreateFactories(*vfs); // Remove cached contents generated during the previous session RemoveCachedContents(); @@ -274,16 +276,16 @@ GMainWindow::GMainWindow(Core::System& system_) ShowTelemetryCallout(); // make sure menubar has the arrow cursor instead of inheriting from this - ui.menubar->setCursor(QCursor()); + ui->menubar->setCursor(QCursor()); statusBar()->setCursor(QCursor()); mouse_hide_timer.setInterval(default_mouse_timeout); connect(&mouse_hide_timer, &QTimer::timeout, this, &GMainWindow::HideMouseCursor); - connect(ui.menubar, &QMenuBar::hovered, this, &GMainWindow::ShowMouseCursor); + connect(ui->menubar, &QMenuBar::hovered, this, &GMainWindow::ShowMouseCursor); MigrateConfigFiles(); - ui.action_Fullscreen->setChecked(false); + ui->action_Fullscreen->setChecked(false); QStringList args = QApplication::arguments(); @@ -302,7 +304,7 @@ GMainWindow::GMainWindow(Core::System& system_) // Launch game in fullscreen mode if (args[i] == QStringLiteral("-f")) { - ui.action_Fullscreen->setChecked(true); + ui->action_Fullscreen->setChecked(true); continue; } @@ -405,12 +407,12 @@ void GMainWindow::RegisterMetaTypes() { qRegisterMetaType<Service::AM::Applets::WebExitReason>("Service::AM::Applets::WebExitReason"); // Register loader types - qRegisterMetaType<Core::System::ResultStatus>("Core::System::ResultStatus"); + qRegisterMetaType<Core::SystemResultStatus>("Core::SystemResultStatus"); } void GMainWindow::ControllerSelectorReconfigureControllers( const Core::Frontend::ControllerParameters& parameters) { - QtControllerSelectorDialog dialog(this, parameters, input_subsystem.get(), system); + QtControllerSelectorDialog dialog(this, parameters, input_subsystem.get(), *system); dialog.setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint | Qt::WindowTitleHint | Qt::WindowSystemMenuHint); @@ -420,7 +422,7 @@ void GMainWindow::ControllerSelectorReconfigureControllers( emit ControllerSelectorReconfigureFinished(); // Don't forget to apply settings. - system.ApplySettings(); + system->ApplySettings(); config->Save(); UpdateStatusButtons(); @@ -454,7 +456,7 @@ void GMainWindow::SoftwareKeyboardInitialize( return; } - software_keyboard = new QtSoftwareKeyboardDialog(render_window, system, is_inline, + software_keyboard = new QtSoftwareKeyboardDialog(render_window, *system, is_inline, std::move(initialize_parameters)); if (is_inline) { @@ -566,11 +568,11 @@ void GMainWindow::WebBrowserOpenWebPage(const std::string& main_url, return; } - QtNXWebEngineView web_browser_view(this, system, input_subsystem.get()); + QtNXWebEngineView web_browser_view(this, *system, input_subsystem.get()); - ui.action_Pause->setEnabled(false); - ui.action_Restart->setEnabled(false); - ui.action_Stop->setEnabled(false); + ui->action_Pause->setEnabled(false); + ui->action_Restart->setEnabled(false); + ui->action_Stop->setEnabled(false); { QProgressDialog loading_progress(this); @@ -634,7 +636,7 @@ void GMainWindow::WebBrowserOpenWebPage(const std::string& main_url, web_browser_view.SetFinished(true); } }); - ui.menubar->addAction(exit_action); + ui->menubar->addAction(exit_action); while (!web_browser_view.IsFinished()) { QCoreApplication::processEvents(); @@ -676,11 +678,11 @@ void GMainWindow::WebBrowserOpenWebPage(const std::string& main_url, render_window->show(); } - ui.action_Pause->setEnabled(true); - ui.action_Restart->setEnabled(true); - ui.action_Stop->setEnabled(true); + ui->action_Pause->setEnabled(true); + ui->action_Restart->setEnabled(true); + ui->action_Stop->setEnabled(true); - ui.menubar->removeAction(exit_action); + ui->menubar->removeAction(exit_action); QCoreApplication::processEvents(); @@ -696,21 +698,21 @@ void GMainWindow::WebBrowserOpenWebPage(const std::string& main_url, void GMainWindow::InitializeWidgets() { #ifdef YUZU_ENABLE_COMPATIBILITY_REPORTING - ui.action_Report_Compatibility->setVisible(true); + ui->action_Report_Compatibility->setVisible(true); #endif - render_window = new GRenderWindow(this, emu_thread.get(), input_subsystem, system); + render_window = new GRenderWindow(this, emu_thread.get(), input_subsystem, *system); render_window->hide(); - game_list = new GameList(vfs, provider.get(), system, this); - ui.horizontalLayout->addWidget(game_list); + game_list = new GameList(vfs, provider.get(), *system, this); + ui->horizontalLayout->addWidget(game_list); game_list_placeholder = new GameListPlaceholder(this); - ui.horizontalLayout->addWidget(game_list_placeholder); + ui->horizontalLayout->addWidget(game_list_placeholder); game_list_placeholder->setVisible(false); loading_screen = new LoadingScreen(this); loading_screen->hide(); - ui.horizontalLayout->addWidget(loading_screen); + ui->horizontalLayout->addWidget(loading_screen); connect(loading_screen, &LoadingScreen::Hidden, [&] { loading_screen->Clear(); if (emulation_running) { @@ -767,14 +769,14 @@ void GMainWindow::InitializeWidgets() { tr("Handheld controller can't be used on docked mode. Pro " "controller will be selected.")); controller_type = Settings::ControllerType::ProController; - ConfigureDialog configure_dialog(this, hotkey_registry, input_subsystem.get(), system); + ConfigureDialog configure_dialog(this, hotkey_registry, input_subsystem.get(), *system); configure_dialog.ApplyConfiguration(); controller_dialog->refreshConfiguration(); } Settings::values.use_docked_mode.SetValue(!is_docked); dock_status_button->setChecked(!is_docked); - OnDockedModeChanged(is_docked, !is_docked, system); + OnDockedModeChanged(is_docked, !is_docked, *system); }); dock_status_button->setText(tr("DOCK")); dock_status_button->setCheckable(true); @@ -798,7 +800,7 @@ void GMainWindow::InitializeWidgets() { } } - system.ApplySettings(); + system->ApplySettings(); UpdateGPUAccuracyButton(); }); UpdateGPUAccuracyButton(); @@ -826,7 +828,7 @@ void GMainWindow::InitializeWidgets() { Settings::values.renderer_backend.SetValue(Settings::RendererBackend::OpenGL); } - system.ApplySettings(); + system->ApplySettings(); }); statusBar()->insertPermanentWidget(0, renderer_status_button); @@ -835,7 +837,7 @@ void GMainWindow::InitializeWidgets() { } void GMainWindow::InitializeDebugWidgets() { - QMenu* debug_menu = ui.menu_View_Debugging; + QMenu* debug_menu = ui->menu_View_Debugging; #if MICROPROFILE_ENABLED microProfileDialog = new MicroProfileDialog(this); @@ -843,7 +845,7 @@ void GMainWindow::InitializeDebugWidgets() { debug_menu->addAction(microProfileDialog->toggleViewAction()); #endif - waitTreeWidget = new WaitTreeWidget(system, this); + waitTreeWidget = new WaitTreeWidget(*system, this); addDockWidget(Qt::LeftDockWidgetArea, waitTreeWidget); waitTreeWidget->hide(); debug_menu->addAction(waitTreeWidget->toggleViewAction()); @@ -864,16 +866,16 @@ void GMainWindow::InitializeRecentFileMenuActions() { actions_recent_files[i]->setVisible(false); connect(actions_recent_files[i], &QAction::triggered, this, &GMainWindow::OnMenuRecentFile); - ui.menu_recent_files->addAction(actions_recent_files[i]); + ui->menu_recent_files->addAction(actions_recent_files[i]); } - ui.menu_recent_files->addSeparator(); + ui->menu_recent_files->addSeparator(); QAction* action_clear_recent_files = new QAction(this); action_clear_recent_files->setText(tr("&Clear Recent Files")); connect(action_clear_recent_files, &QAction::triggered, this, [this] { UISettings::values.recent_files.clear(); UpdateRecentFiles(); }); - ui.menu_recent_files->addAction(action_clear_recent_files); + ui->menu_recent_files->addAction(action_clear_recent_files); UpdateRecentFiles(); } @@ -892,43 +894,43 @@ void GMainWindow::InitializeHotkeys() { const QString fullscreen = QStringLiteral("Fullscreen"); const QString capture_screenshot = QStringLiteral("Capture Screenshot"); - ui.action_Load_File->setShortcut(hotkey_registry.GetKeySequence(main_window, load_file)); - ui.action_Load_File->setShortcutContext( + ui->action_Load_File->setShortcut(hotkey_registry.GetKeySequence(main_window, load_file)); + ui->action_Load_File->setShortcutContext( hotkey_registry.GetShortcutContext(main_window, load_file)); - ui.action_Load_Amiibo->setShortcut(hotkey_registry.GetKeySequence(main_window, load_amiibo)); - ui.action_Load_Amiibo->setShortcutContext( + ui->action_Load_Amiibo->setShortcut(hotkey_registry.GetKeySequence(main_window, load_amiibo)); + ui->action_Load_Amiibo->setShortcutContext( hotkey_registry.GetShortcutContext(main_window, load_amiibo)); - ui.action_Exit->setShortcut(hotkey_registry.GetKeySequence(main_window, exit_yuzu)); - ui.action_Exit->setShortcutContext(hotkey_registry.GetShortcutContext(main_window, exit_yuzu)); + ui->action_Exit->setShortcut(hotkey_registry.GetKeySequence(main_window, exit_yuzu)); + ui->action_Exit->setShortcutContext(hotkey_registry.GetShortcutContext(main_window, exit_yuzu)); - ui.action_Restart->setShortcut(hotkey_registry.GetKeySequence(main_window, restart_emulation)); - ui.action_Restart->setShortcutContext( + ui->action_Restart->setShortcut(hotkey_registry.GetKeySequence(main_window, restart_emulation)); + ui->action_Restart->setShortcutContext( hotkey_registry.GetShortcutContext(main_window, restart_emulation)); - ui.action_Stop->setShortcut(hotkey_registry.GetKeySequence(main_window, stop_emulation)); - ui.action_Stop->setShortcutContext( + ui->action_Stop->setShortcut(hotkey_registry.GetKeySequence(main_window, stop_emulation)); + ui->action_Stop->setShortcutContext( hotkey_registry.GetShortcutContext(main_window, stop_emulation)); - ui.action_Show_Filter_Bar->setShortcut( + ui->action_Show_Filter_Bar->setShortcut( hotkey_registry.GetKeySequence(main_window, toggle_filter_bar)); - ui.action_Show_Filter_Bar->setShortcutContext( + ui->action_Show_Filter_Bar->setShortcutContext( hotkey_registry.GetShortcutContext(main_window, toggle_filter_bar)); - ui.action_Show_Status_Bar->setShortcut( + ui->action_Show_Status_Bar->setShortcut( hotkey_registry.GetKeySequence(main_window, toggle_status_bar)); - ui.action_Show_Status_Bar->setShortcutContext( + ui->action_Show_Status_Bar->setShortcutContext( hotkey_registry.GetShortcutContext(main_window, toggle_status_bar)); - ui.action_Capture_Screenshot->setShortcut( + ui->action_Capture_Screenshot->setShortcut( hotkey_registry.GetKeySequence(main_window, capture_screenshot)); - ui.action_Capture_Screenshot->setShortcutContext( + ui->action_Capture_Screenshot->setShortcutContext( hotkey_registry.GetShortcutContext(main_window, capture_screenshot)); - ui.action_Fullscreen->setShortcut( + ui->action_Fullscreen->setShortcut( hotkey_registry.GetHotkey(main_window, fullscreen, this)->key()); - ui.action_Fullscreen->setShortcutContext( + ui->action_Fullscreen->setShortcutContext( hotkey_registry.GetShortcutContext(main_window, fullscreen)); connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("Load File"), this), @@ -946,19 +948,19 @@ void GMainWindow::InitializeHotkeys() { }); connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("Restart Emulation"), this), &QShortcut::activated, this, [this] { - if (!system.IsPoweredOn()) { + if (!system->IsPoweredOn()) { return; } BootGame(game_path); }); connect(hotkey_registry.GetHotkey(main_window, fullscreen, render_window), - &QShortcut::activated, ui.action_Fullscreen, &QAction::trigger); + &QShortcut::activated, ui->action_Fullscreen, &QAction::trigger); connect(hotkey_registry.GetHotkey(main_window, fullscreen, render_window), - &QShortcut::activatedAmbiguously, ui.action_Fullscreen, &QAction::trigger); + &QShortcut::activatedAmbiguously, ui->action_Fullscreen, &QAction::trigger); connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("Exit Fullscreen"), this), &QShortcut::activated, this, [&] { if (emulation_running) { - ui.action_Fullscreen->setChecked(false); + ui->action_Fullscreen->setChecked(false); ToggleFullscreen(); } }); @@ -987,7 +989,7 @@ void GMainWindow::InitializeHotkeys() { }); connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("Load Amiibo"), this), &QShortcut::activated, this, [&] { - if (ui.action_Load_Amiibo->isEnabled()) { + if (ui->action_Load_Amiibo->isEnabled()) { OnLoadAmiibo(); } }); @@ -1002,7 +1004,7 @@ void GMainWindow::InitializeHotkeys() { Settings::values.use_docked_mode.SetValue( !Settings::values.use_docked_mode.GetValue()); OnDockedModeChanged(!Settings::values.use_docked_mode.GetValue(), - Settings::values.use_docked_mode.GetValue(), system); + Settings::values.use_docked_mode.GetValue(), *system); dock_status_button->setChecked(Settings::values.use_docked_mode.GetValue()); }); connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("Mute Audio"), this), @@ -1068,20 +1070,20 @@ void GMainWindow::RestoreUIState() { game_list->LoadInterfaceLayout(); - ui.action_Single_Window_Mode->setChecked(UISettings::values.single_window_mode.GetValue()); + ui->action_Single_Window_Mode->setChecked(UISettings::values.single_window_mode.GetValue()); ToggleWindowMode(); - ui.action_Fullscreen->setChecked(UISettings::values.fullscreen.GetValue()); + ui->action_Fullscreen->setChecked(UISettings::values.fullscreen.GetValue()); - ui.action_Display_Dock_Widget_Headers->setChecked( + ui->action_Display_Dock_Widget_Headers->setChecked( UISettings::values.display_titlebar.GetValue()); - OnDisplayTitleBars(ui.action_Display_Dock_Widget_Headers->isChecked()); + OnDisplayTitleBars(ui->action_Display_Dock_Widget_Headers->isChecked()); - ui.action_Show_Filter_Bar->setChecked(UISettings::values.show_filter_bar.GetValue()); - game_list->SetFilterVisible(ui.action_Show_Filter_Bar->isChecked()); + ui->action_Show_Filter_Bar->setChecked(UISettings::values.show_filter_bar.GetValue()); + game_list->SetFilterVisible(ui->action_Show_Filter_Bar->isChecked()); - ui.action_Show_Status_Bar->setChecked(UISettings::values.show_status_bar.GetValue()); - statusBar()->setVisible(ui.action_Show_Status_Bar->isChecked()); + ui->action_Show_Status_Bar->setChecked(UISettings::values.show_status_bar.GetValue()); + statusBar()->setVisible(ui->action_Show_Status_Bar->isChecked()); Debugger::ToggleConsole(); } @@ -1093,11 +1095,11 @@ void GMainWindow::OnAppFocusStateChanged(Qt::ApplicationState state) { state != Qt::ApplicationActive) { LOG_DEBUG(Frontend, "ApplicationState unusual flag: {} ", state); } - if (ui.action_Pause->isEnabled() && + if (ui->action_Pause->isEnabled() && (state & (Qt::ApplicationHidden | Qt::ApplicationInactive))) { auto_paused = true; OnPauseGame(); - } else if (ui.action_Start->isEnabled() && auto_paused && state == Qt::ApplicationActive) { + } else if (ui->action_Start->isEnabled() && auto_paused && state == Qt::ApplicationActive) { auto_paused = false; OnStartGame(); } @@ -1142,59 +1144,60 @@ void GMainWindow::ConnectWidgetEvents() { void GMainWindow::ConnectMenuEvents() { // File - connect(ui.action_Load_File, &QAction::triggered, this, &GMainWindow::OnMenuLoadFile); - connect(ui.action_Load_Folder, &QAction::triggered, this, &GMainWindow::OnMenuLoadFolder); - connect(ui.action_Install_File_NAND, &QAction::triggered, this, + connect(ui->action_Load_File, &QAction::triggered, this, &GMainWindow::OnMenuLoadFile); + connect(ui->action_Load_Folder, &QAction::triggered, this, &GMainWindow::OnMenuLoadFolder); + connect(ui->action_Install_File_NAND, &QAction::triggered, this, &GMainWindow::OnMenuInstallToNAND); - connect(ui.action_Exit, &QAction::triggered, this, &QMainWindow::close); - connect(ui.action_Load_Amiibo, &QAction::triggered, this, &GMainWindow::OnLoadAmiibo); + connect(ui->action_Exit, &QAction::triggered, this, &QMainWindow::close); + connect(ui->action_Load_Amiibo, &QAction::triggered, this, &GMainWindow::OnLoadAmiibo); // Emulation - connect(ui.action_Start, &QAction::triggered, this, &GMainWindow::OnStartGame); - connect(ui.action_Pause, &QAction::triggered, this, &GMainWindow::OnPauseGame); - connect(ui.action_Stop, &QAction::triggered, this, &GMainWindow::OnStopGame); - connect(ui.action_Report_Compatibility, &QAction::triggered, this, + connect(ui->action_Start, &QAction::triggered, this, &GMainWindow::OnStartGame); + connect(ui->action_Pause, &QAction::triggered, this, &GMainWindow::OnPauseGame); + connect(ui->action_Stop, &QAction::triggered, this, &GMainWindow::OnStopGame); + connect(ui->action_Report_Compatibility, &QAction::triggered, this, &GMainWindow::OnMenuReportCompatibility); - connect(ui.action_Open_Mods_Page, &QAction::triggered, this, &GMainWindow::OnOpenModsPage); - connect(ui.action_Open_Quickstart_Guide, &QAction::triggered, this, + connect(ui->action_Open_Mods_Page, &QAction::triggered, this, &GMainWindow::OnOpenModsPage); + connect(ui->action_Open_Quickstart_Guide, &QAction::triggered, this, &GMainWindow::OnOpenQuickstartGuide); - connect(ui.action_Open_FAQ, &QAction::triggered, this, &GMainWindow::OnOpenFAQ); - connect(ui.action_Restart, &QAction::triggered, this, [this] { BootGame(QString(game_path)); }); - connect(ui.action_Configure, &QAction::triggered, this, &GMainWindow::OnConfigure); - connect(ui.action_Configure_Tas, &QAction::triggered, this, &GMainWindow::OnConfigureTas); - connect(ui.action_Configure_Current_Game, &QAction::triggered, this, + connect(ui->action_Open_FAQ, &QAction::triggered, this, &GMainWindow::OnOpenFAQ); + connect(ui->action_Restart, &QAction::triggered, this, + [this] { BootGame(QString(game_path)); }); + connect(ui->action_Configure, &QAction::triggered, this, &GMainWindow::OnConfigure); + connect(ui->action_Configure_Tas, &QAction::triggered, this, &GMainWindow::OnConfigureTas); + connect(ui->action_Configure_Current_Game, &QAction::triggered, this, &GMainWindow::OnConfigurePerGame); // View - connect(ui.action_Single_Window_Mode, &QAction::triggered, this, + connect(ui->action_Single_Window_Mode, &QAction::triggered, this, &GMainWindow::ToggleWindowMode); - connect(ui.action_Display_Dock_Widget_Headers, &QAction::triggered, this, + connect(ui->action_Display_Dock_Widget_Headers, &QAction::triggered, this, &GMainWindow::OnDisplayTitleBars); - connect(ui.action_Show_Filter_Bar, &QAction::triggered, this, &GMainWindow::OnToggleFilterBar); - connect(ui.action_Show_Status_Bar, &QAction::triggered, statusBar(), &QStatusBar::setVisible); + connect(ui->action_Show_Filter_Bar, &QAction::triggered, this, &GMainWindow::OnToggleFilterBar); + connect(ui->action_Show_Status_Bar, &QAction::triggered, statusBar(), &QStatusBar::setVisible); - connect(ui.action_Reset_Window_Size_720, &QAction::triggered, this, + connect(ui->action_Reset_Window_Size_720, &QAction::triggered, this, &GMainWindow::ResetWindowSize720); - connect(ui.action_Reset_Window_Size_900, &QAction::triggered, this, + connect(ui->action_Reset_Window_Size_900, &QAction::triggered, this, &GMainWindow::ResetWindowSize900); - connect(ui.action_Reset_Window_Size_1080, &QAction::triggered, this, + connect(ui->action_Reset_Window_Size_1080, &QAction::triggered, this, &GMainWindow::ResetWindowSize1080); - ui.menu_Reset_Window_Size->addAction(ui.action_Reset_Window_Size_720); - ui.menu_Reset_Window_Size->addAction(ui.action_Reset_Window_Size_900); - ui.menu_Reset_Window_Size->addAction(ui.action_Reset_Window_Size_1080); + ui->menu_Reset_Window_Size->addAction(ui->action_Reset_Window_Size_720); + ui->menu_Reset_Window_Size->addAction(ui->action_Reset_Window_Size_900); + ui->menu_Reset_Window_Size->addAction(ui->action_Reset_Window_Size_1080); // Fullscreen - connect(ui.action_Fullscreen, &QAction::triggered, this, &GMainWindow::ToggleFullscreen); + connect(ui->action_Fullscreen, &QAction::triggered, this, &GMainWindow::ToggleFullscreen); // Movie - connect(ui.action_Capture_Screenshot, &QAction::triggered, this, + connect(ui->action_Capture_Screenshot, &QAction::triggered, this, &GMainWindow::OnCaptureScreenshot); // Help - connect(ui.action_Open_yuzu_Folder, &QAction::triggered, this, &GMainWindow::OnOpenYuzuFolder); - connect(ui.action_Rederive, &QAction::triggered, this, + connect(ui->action_Open_yuzu_Folder, &QAction::triggered, this, &GMainWindow::OnOpenYuzuFolder); + connect(ui->action_Rederive, &QAction::triggered, this, std::bind(&GMainWindow::OnReinitializeKeys, this, ReinitializeKeyBehavior::Warning)); - connect(ui.action_About, &QAction::triggered, this, &GMainWindow::OnAbout); + connect(ui->action_About, &QAction::triggered, this, &GMainWindow::OnAbout); } void GMainWindow::OnDisplayTitleBars(bool show) { @@ -1238,9 +1241,9 @@ bool GMainWindow::LoadROM(const QString& filename, u64 program_id, std::size_t p return false; } - system.SetFilesystem(vfs); + system->SetFilesystem(vfs); - system.SetAppletFrontendSet({ + system->SetAppletFrontendSet({ std::make_unique<QtControllerSelector>(*this), // Controller Selector std::make_unique<QtErrorDisplay>(*this), // Error Display nullptr, // Parental Controls @@ -1250,14 +1253,14 @@ bool GMainWindow::LoadROM(const QString& filename, u64 program_id, std::size_t p std::make_unique<QtWebBrowser>(*this), // Web Browser }); - const Core::System::ResultStatus result{ - system.Load(*render_window, filename.toStdString(), program_id, program_index)}; + const Core::SystemResultStatus result{ + system->Load(*render_window, filename.toStdString(), program_id, program_index)}; const auto drd_callout = (UISettings::values.callout_flags.GetValue() & static_cast<u32>(CalloutFlag::DRDDeprecation)) == 0; - if (result == Core::System::ResultStatus::Success && - system.GetAppLoader().GetFileType() == Loader::FileType::DeconstructedRomDirectory && + if (result == Core::SystemResultStatus::Success && + system->GetAppLoader().GetFileType() == Loader::FileType::DeconstructedRomDirectory && drd_callout) { UISettings::values.callout_flags = UISettings::values.callout_flags.GetValue() | static_cast<u32>(CalloutFlag::DRDDeprecation); @@ -1271,14 +1274,14 @@ bool GMainWindow::LoadROM(const QString& filename, u64 program_id, std::size_t p "wiki</a>. This message will not be shown again.")); } - if (result != Core::System::ResultStatus::Success) { + if (result != Core::SystemResultStatus::Success) { switch (result) { - case Core::System::ResultStatus::ErrorGetLoader: + case Core::SystemResultStatus::ErrorGetLoader: LOG_CRITICAL(Frontend, "Failed to obtain loader for {}!", filename.toStdString()); QMessageBox::critical(this, tr("Error while loading ROM!"), tr("The ROM format is not supported.")); break; - case Core::System::ResultStatus::ErrorVideoCore: + case Core::SystemResultStatus::ErrorVideoCore: QMessageBox::critical( this, tr("An error occurred initializing the video core."), tr("yuzu has encountered an error while running the video core, please see the " @@ -1292,8 +1295,8 @@ bool GMainWindow::LoadROM(const QString& filename, u64 program_id, std::size_t p break; default: - if (result > Core::System::ResultStatus::ErrorLoader) { - const u16 loader_id = static_cast<u16>(Core::System::ResultStatus::ErrorLoader); + if (result > Core::SystemResultStatus::ErrorLoader) { + const u16 loader_id = static_cast<u16>(Core::SystemResultStatus::ErrorLoader); const u16 error_id = static_cast<u16>(result) - loader_id; const std::string error_code = fmt::format("({:04X}-{:04X})", loader_id, error_id); LOG_CRITICAL(Frontend, "Failed to load ROM! {}", error_code); @@ -1321,7 +1324,7 @@ bool GMainWindow::LoadROM(const QString& filename, u64 program_id, std::size_t p } game_path = filename; - system.TelemetrySession().AddField(Common::Telemetry::FieldType::App, "Frontend", "Qt"); + system->TelemetrySession().AddField(Common::Telemetry::FieldType::App, "Frontend", "Qt"); return true; } @@ -1348,7 +1351,7 @@ void GMainWindow::BootGame(const QString& filename, u64 program_id, std::size_t last_filename_booted = filename; const auto v_file = Core::GetGameFileFromPath(vfs, filename.toUtf8().constData()); - const auto loader = Loader::GetLoader(system, v_file, program_id, program_index); + const auto loader = Loader::GetLoader(*system, v_file, program_id, program_index); if (loader != nullptr && loader->ReadProgramId(title_id) == Loader::ResultStatus::Success && type == StartGameType::Normal) { @@ -1357,7 +1360,7 @@ void GMainWindow::BootGame(const QString& filename, u64 program_id, std::size_t const auto config_file_name = title_id == 0 ? Common::FS::PathToUTF8String(file_path.filename()) : fmt::format("{:016X}", title_id); - Config per_game_config(system, config_file_name, Config::ConfigType::PerGameConfig); + Config per_game_config(*system, config_file_name, Config::ConfigType::PerGameConfig); } ConfigureVibration::SetAllVibrationDevices(); @@ -1380,16 +1383,16 @@ void GMainWindow::BootGame(const QString& filename, u64 program_id, std::size_t return; // Create and start the emulation thread - emu_thread = std::make_unique<EmuThread>(system); + emu_thread = std::make_unique<EmuThread>(*system); emit EmulationStarting(emu_thread.get()); emu_thread->start(); // Register an ExecuteProgram callback such that Core can execute a sub-program - system.RegisterExecuteProgramCallback( + system->RegisterExecuteProgramCallback( [this](std::size_t program_index) { render_window->ExecuteProgram(program_index); }); // Register an Exit callback such that Core can exit the currently running application. - system.RegisterExitCallback([this]() { render_window->Exit(); }); + system->RegisterExitCallback([this]() { render_window->Exit(); }); connect(render_window, &GRenderWindow::Closed, this, &GMainWindow::OnStopGame); connect(render_window, &GRenderWindow::MouseActivity, this, &GMainWindow::OnMouseActivity); @@ -1405,7 +1408,7 @@ void GMainWindow::BootGame(const QString& filename, u64 program_id, std::size_t // Update the GUI UpdateStatusButtons(); - if (ui.action_Single_Window_Mode->isChecked()) { + if (ui->action_Single_Window_Mode->isChecked()) { game_list->hide(); game_list_placeholder->hide(); } @@ -1423,11 +1426,11 @@ void GMainWindow::BootGame(const QString& filename, u64 program_id, std::size_t std::string title_name; std::string title_version; - const auto res = system.GetGameName(title_name); + const auto res = system->GetGameName(title_name); const auto metadata = [this, title_id] { - const FileSys::PatchManager pm(title_id, system.GetFileSystemController(), - system.GetContentProvider()); + const FileSys::PatchManager pm(title_id, system->GetFileSystemController(), + system->GetContentProvider()); return pm.GetControlMetadata(); }(); if (metadata.first != nullptr) { @@ -1438,20 +1441,20 @@ void GMainWindow::BootGame(const QString& filename, u64 program_id, std::size_t title_name = Common::FS::PathToUTF8String( std::filesystem::path{filename.toStdU16String()}.filename()); } - const bool is_64bit = system.Kernel().CurrentProcess()->Is64BitProcess(); + const bool is_64bit = system->Kernel().CurrentProcess()->Is64BitProcess(); const auto instruction_set_suffix = is_64bit ? tr("(64-bit)") : tr("(32-bit)"); title_name = tr("%1 %2", "%1 is the title name. %2 indicates if the title is 64-bit or 32-bit") .arg(QString::fromStdString(title_name), instruction_set_suffix) .toStdString(); LOG_INFO(Frontend, "Booting game: {:016X} | {} | {}", title_id, title_name, title_version); - const auto gpu_vendor = system.GPU().Renderer().GetDeviceVendor(); + const auto gpu_vendor = system->GPU().Renderer().GetDeviceVendor(); UpdateWindowTitle(title_name, title_version, gpu_vendor); - loading_screen->Prepare(system.GetAppLoader()); + loading_screen->Prepare(system->GetAppLoader()); loading_screen->show(); emulation_running = true; - if (ui.action_Fullscreen->isChecked()) { + if (ui->action_Fullscreen->isChecked()) { ShowFullscreen(); } OnStartGame(); @@ -1462,7 +1465,7 @@ void GMainWindow::ShutdownGame() { return; } - if (ui.action_Fullscreen->isChecked()) { + if (ui->action_Fullscreen->isChecked()) { HideFullscreen(); } @@ -1483,15 +1486,15 @@ void GMainWindow::ShutdownGame() { disconnect(render_window, &GRenderWindow::Closed, this, &GMainWindow::OnStopGame); // Update the GUI - ui.action_Start->setEnabled(false); - ui.action_Start->setText(tr("Start")); - ui.action_Pause->setEnabled(false); - ui.action_Stop->setEnabled(false); - ui.action_Restart->setEnabled(false); - ui.action_Configure_Current_Game->setEnabled(false); - ui.action_Report_Compatibility->setEnabled(false); - ui.action_Load_Amiibo->setEnabled(false); - ui.action_Capture_Screenshot->setEnabled(false); + ui->action_Start->setEnabled(false); + ui->action_Start->setText(tr("Start")); + ui->action_Pause->setEnabled(false); + ui->action_Stop->setEnabled(false); + ui->action_Restart->setEnabled(false); + ui->action_Configure_Current_Game->setEnabled(false); + ui->action_Report_Compatibility->setEnabled(false); + ui->action_Load_Amiibo->setEnabled(false); + ui->action_Capture_Screenshot->setEnabled(false); render_window->hide(); loading_screen->hide(); loading_screen->Clear(); @@ -1553,7 +1556,7 @@ void GMainWindow::UpdateRecentFiles() { } // Enable the recent files menu if the list isn't empty - ui.menu_recent_files->setEnabled(num_recent_files != 0); + ui->menu_recent_files->setEnabled(num_recent_files != 0); } void GMainWindow::OnGameListLoadFile(QString game_path, u64 program_id) { @@ -1566,15 +1569,15 @@ void GMainWindow::OnGameListOpenFolder(u64 program_id, GameListOpenTarget target QString open_target; const auto [user_save_size, device_save_size] = [this, &game_path, &program_id] { - const FileSys::PatchManager pm{program_id, system.GetFileSystemController(), - system.GetContentProvider()}; + const FileSys::PatchManager pm{program_id, system->GetFileSystemController(), + system->GetContentProvider()}; const auto control = pm.GetControlMetadata().first; if (control != nullptr) { return std::make_pair(control->GetDefaultNormalSaveSize(), control->GetDeviceSaveDataSize()); } else { const auto file = Core::GetGameFileFromPath(vfs, game_path); - const auto loader = Loader::GetLoader(system, file); + const auto loader = Loader::GetLoader(*system, file); FileSys::NACP nacp{}; loader->ReadControlData(nacp); @@ -1617,14 +1620,14 @@ void GMainWindow::OnGameListOpenFolder(u64 program_id, GameListOpenTarget target ASSERT(user_id); const auto user_save_data_path = FileSys::SaveDataFactory::GetFullPath( - system, FileSys::SaveDataSpaceId::NandUser, FileSys::SaveDataType::SaveData, + *system, FileSys::SaveDataSpaceId::NandUser, FileSys::SaveDataType::SaveData, program_id, user_id->uuid, 0); path = Common::FS::ConcatPathSafe(nand_dir, user_save_data_path); } else { // Device save data const auto device_save_data_path = FileSys::SaveDataFactory::GetFullPath( - system, FileSys::SaveDataSpaceId::NandUser, FileSys::SaveDataType::SaveData, + *system, FileSys::SaveDataSpaceId::NandUser, FileSys::SaveDataType::SaveData, program_id, {}, 0); path = Common::FS::ConcatPathSafe(nand_dir, device_save_data_path); @@ -1663,7 +1666,7 @@ void GMainWindow::OnTransferableShaderCacheOpenFile(u64 program_id) { const auto shader_cache_folder_path{shader_cache_dir / fmt::format("{:016x}", program_id)}; if (!Common::FS::CreateDirs(shader_cache_folder_path)) { QMessageBox::warning(this, tr("Error Opening Transferable Shader Cache"), - tr("Filed to create the shader cache directory for this title.")); + tr("Failed to create the shader cache directory for this title.")); return; } const auto shader_path_string{Common::FS::PathToUTF8String(shader_cache_folder_path)}; @@ -1751,7 +1754,7 @@ void GMainWindow::OnGameListRemoveInstalledEntry(u64 program_id, InstalledEntryT } void GMainWindow::RemoveBaseContent(u64 program_id, const QString& entry_type) { - const auto& fs_controller = system.GetFileSystemController(); + const auto& fs_controller = system->GetFileSystemController(); const auto res = fs_controller.GetUserNANDContents()->RemoveExistingEntry(program_id) || fs_controller.GetSDMCContents()->RemoveExistingEntry(program_id); @@ -1767,7 +1770,7 @@ void GMainWindow::RemoveBaseContent(u64 program_id, const QString& entry_type) { void GMainWindow::RemoveUpdateContent(u64 program_id, const QString& entry_type) { const auto update_id = program_id | 0x800; - const auto& fs_controller = system.GetFileSystemController(); + const auto& fs_controller = system->GetFileSystemController(); const auto res = fs_controller.GetUserNANDContents()->RemoveExistingEntry(update_id) || fs_controller.GetSDMCContents()->RemoveExistingEntry(update_id); @@ -1782,8 +1785,8 @@ void GMainWindow::RemoveUpdateContent(u64 program_id, const QString& entry_type) void GMainWindow::RemoveAddOnContent(u64 program_id, const QString& entry_type) { u32 count{}; - const auto& fs_controller = system.GetFileSystemController(); - const auto dlc_entries = system.GetContentProvider().ListEntriesFilter( + const auto& fs_controller = system->GetFileSystemController(); + const auto dlc_entries = system->GetContentProvider().ListEntriesFilter( FileSys::TitleType::AOC, FileSys::ContentRecordType::Data); for (const auto& entry : dlc_entries) { @@ -1921,7 +1924,7 @@ void GMainWindow::OnGameListDumpRomFS(u64 program_id, const std::string& game_pa "cancelled the operation.")); }; - const auto loader = Loader::GetLoader(system, vfs->OpenFile(game_path, FileSys::Mode::Read)); + const auto loader = Loader::GetLoader(*system, vfs->OpenFile(game_path, FileSys::Mode::Read)); if (loader == nullptr) { failed(); return; @@ -1933,7 +1936,7 @@ void GMainWindow::OnGameListDumpRomFS(u64 program_id, const std::string& game_pa return; } - const auto& installed = system.GetContentProvider(); + const auto& installed = system->GetContentProvider(); const auto romfs_title_id = SelectRomFSDumpTarget(installed, program_id); if (!romfs_title_id) { @@ -1953,7 +1956,7 @@ void GMainWindow::OnGameListDumpRomFS(u64 program_id, const std::string& game_pa if (*romfs_title_id == program_id) { const u64 ivfc_offset = loader->ReadRomFSIVFCOffset(); - const FileSys::PatchManager pm{program_id, system.GetFileSystemController(), installed}; + const FileSys::PatchManager pm{program_id, system->GetFileSystemController(), installed}; romfs = pm.PatchRomFS(file, ivfc_offset, FileSys::ContentRecordType::Program, nullptr, false); } else { @@ -2079,7 +2082,7 @@ void GMainWindow::OnGameListAddDirectory() { } void GMainWindow::OnGameListShowList(bool show) { - if (emulation_running && ui.action_Single_Window_Mode->isChecked()) + if (emulation_running && ui->action_Single_Window_Mode->isChecked()) return; game_list->setVisible(show); game_list_placeholder->setVisible(!show); @@ -2088,7 +2091,7 @@ void GMainWindow::OnGameListShowList(bool show) { void GMainWindow::OnGameListOpenPerGameProperties(const std::string& file) { u64 title_id{}; const auto v_file = Core::GetGameFileFromPath(vfs, file); - const auto loader = Loader::GetLoader(system, v_file); + const auto loader = Loader::GetLoader(*system, v_file); if (loader == nullptr || loader->ReadProgramId(title_id) != Loader::ResultStatus::Success) { QMessageBox::information(this, tr("Properties"), @@ -2181,7 +2184,7 @@ void GMainWindow::OnMenuInstallToNAND() { QStringList failed_files{}; // Files that failed to install due to errors bool detected_base_install{}; // Whether a base game was attempted to be installed - ui.action_Install_File_NAND->setEnabled(false); + ui->action_Install_File_NAND->setEnabled(false); install_progress = new QProgressDialog(QString{}, tr("Cancel"), 0, total_size, this); install_progress->setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint & @@ -2257,7 +2260,7 @@ void GMainWindow::OnMenuInstallToNAND() { Common::FS::RemoveDirRecursively(Common::FS::GetYuzuPath(Common::FS::YuzuPath::CacheDir) / "game_list"); game_list->PopulateAsync(UISettings::values.game_dirs); - ui.action_Install_File_NAND->setEnabled(true); + ui->action_Install_File_NAND->setEnabled(true); } InstallResult GMainWindow::InstallNSPXCI(const QString& filename) { @@ -2302,7 +2305,7 @@ InstallResult GMainWindow::InstallNSPXCI(const QString& filename) { if (nsp->GetStatus() != Loader::ResultStatus::Success) { return InstallResult::Failure; } - const auto res = system.GetFileSystemController().GetUserNANDContents()->InstallEntry( + const auto res = system->GetFileSystemController().GetUserNANDContents()->InstallEntry( *nsp, true, qt_raw_copy); switch (res) { case FileSys::InstallResult::Success: @@ -2381,15 +2384,13 @@ InstallResult GMainWindow::InstallNCA(const QString& filename) { static_cast<size_t>(FileSys::TitleType::FirmwarePackageB); } - FileSys::InstallResult res; - if (index >= static_cast<s32>(FileSys::TitleType::Application)) { - res = system.GetFileSystemController().GetUserNANDContents()->InstallEntry( - *nca, static_cast<FileSys::TitleType>(index), true, qt_raw_copy); - } else { - res = system.GetFileSystemController().GetSystemNANDContents()->InstallEntry( - *nca, static_cast<FileSys::TitleType>(index), true, qt_raw_copy); - } + const bool is_application = index >= static_cast<s32>(FileSys::TitleType::Application); + const auto& fs_controller = system->GetFileSystemController(); + auto* registered_cache = is_application ? fs_controller.GetUserNANDContents() + : fs_controller.GetSystemNANDContents(); + const auto res = registered_cache->InstallEntry(*nca, static_cast<FileSys::TitleType>(index), + true, qt_raw_copy); if (res == FileSys::InstallResult::Success) { return InstallResult::Success; } else if (res == FileSys::InstallResult::OverwriteExisting) { @@ -2423,39 +2424,39 @@ void GMainWindow::OnStartGame() { connect(emu_thread.get(), &EmuThread::ErrorThrown, this, &GMainWindow::OnCoreError); - ui.action_Start->setEnabled(false); - ui.action_Start->setText(tr("&Continue")); + ui->action_Start->setEnabled(false); + ui->action_Start->setText(tr("&Continue")); - ui.action_Pause->setEnabled(true); - ui.action_Stop->setEnabled(true); - ui.action_Restart->setEnabled(true); - ui.action_Configure_Current_Game->setEnabled(true); - ui.action_Report_Compatibility->setEnabled(true); + ui->action_Pause->setEnabled(true); + ui->action_Stop->setEnabled(true); + ui->action_Restart->setEnabled(true); + ui->action_Configure_Current_Game->setEnabled(true); + ui->action_Report_Compatibility->setEnabled(true); discord_rpc->Update(); - ui.action_Load_Amiibo->setEnabled(true); - ui.action_Capture_Screenshot->setEnabled(true); + ui->action_Load_Amiibo->setEnabled(true); + ui->action_Capture_Screenshot->setEnabled(true); } void GMainWindow::OnPauseGame() { emu_thread->SetRunning(false); - ui.action_Start->setEnabled(true); - ui.action_Pause->setEnabled(false); - ui.action_Stop->setEnabled(true); - ui.action_Capture_Screenshot->setEnabled(false); + ui->action_Start->setEnabled(true); + ui->action_Pause->setEnabled(false); + ui->action_Stop->setEnabled(true); + ui->action_Capture_Screenshot->setEnabled(false); AllowOSSleep(); } void GMainWindow::OnStopGame() { - if (system.GetExitLock() && !ConfirmForceLockedExit()) { + if (system->GetExitLock() && !ConfirmForceLockedExit()) { return; } ShutdownGame(); - Settings::RestoreGlobalState(system.IsPoweredOn()); + Settings::RestoreGlobalState(system->IsPoweredOn()); UpdateStatusButtons(); } @@ -2473,7 +2474,7 @@ void GMainWindow::OnExit() { } void GMainWindow::ErrorDisplayDisplayError(QString error_code, QString error_text) { - OverlayDialog dialog(render_window, system, error_code, error_text, QString{}, tr("OK"), + OverlayDialog dialog(render_window, *system, error_code, error_text, QString{}, tr("OK"), Qt::AlignLeft | Qt::AlignVCenter); dialog.exec(); @@ -2483,7 +2484,7 @@ void GMainWindow::ErrorDisplayDisplayError(QString error_code, QString error_tex void GMainWindow::OnMenuReportCompatibility() { if (!Settings::values.yuzu_token.GetValue().empty() && !Settings::values.yuzu_username.GetValue().empty()) { - CompatDB compatdb{system.TelemetrySession(), this}; + CompatDB compatdb{system->TelemetrySession(), this}; compatdb.exec(); } else { QMessageBox::critical( @@ -2519,7 +2520,7 @@ void GMainWindow::ToggleFullscreen() { if (!emulation_running) { return; } - if (ui.action_Fullscreen->isChecked()) { + if (ui->action_Fullscreen->isChecked()) { ShowFullscreen(); } else { HideFullscreen(); @@ -2527,10 +2528,10 @@ void GMainWindow::ToggleFullscreen() { } void GMainWindow::ShowFullscreen() { - if (ui.action_Single_Window_Mode->isChecked()) { + if (ui->action_Single_Window_Mode->isChecked()) { UISettings::values.geometry = saveGeometry(); - ui.menubar->hide(); + ui->menubar->hide(); statusBar()->hide(); if (Settings::values.fullscreen_mode.GetValue() == Settings::FullscreenMode::Exclusive) { @@ -2564,7 +2565,7 @@ void GMainWindow::ShowFullscreen() { } void GMainWindow::HideFullscreen() { - if (ui.action_Single_Window_Mode->isChecked()) { + if (ui->action_Single_Window_Mode->isChecked()) { if (Settings::values.fullscreen_mode.GetValue() == Settings::FullscreenMode::Exclusive) { showNormal(); restoreGeometry(UISettings::values.geometry); @@ -2576,8 +2577,8 @@ void GMainWindow::HideFullscreen() { show(); } - statusBar()->setVisible(ui.action_Show_Status_Bar->isChecked()); - ui.menubar->show(); + statusBar()->setVisible(ui->action_Show_Status_Bar->isChecked()); + ui->menubar->show(); } else { if (Settings::values.fullscreen_mode.GetValue() == Settings::FullscreenMode::Exclusive) { render_window->showNormal(); @@ -2593,10 +2594,10 @@ void GMainWindow::HideFullscreen() { } void GMainWindow::ToggleWindowMode() { - if (ui.action_Single_Window_Mode->isChecked()) { + if (ui->action_Single_Window_Mode->isChecked()) { // Render in the main window... render_window->BackupGeometry(); - ui.horizontalLayout->addWidget(render_window); + ui->horizontalLayout->addWidget(render_window); render_window->setFocusPolicy(Qt::StrongFocus); if (emulation_running) { render_window->setVisible(true); @@ -2606,7 +2607,7 @@ void GMainWindow::ToggleWindowMode() { } else { // Render in a separate window... - ui.horizontalLayout->removeWidget(render_window); + ui->horizontalLayout->removeWidget(render_window); render_window->setParent(nullptr); render_window->setFocusPolicy(Qt::NoFocus); if (emulation_running) { @@ -2621,10 +2622,10 @@ void GMainWindow::ResetWindowSize(u32 width, u32 height) { const auto aspect_ratio = Layout::EmulationAspectRatio( static_cast<Layout::AspectRatio>(Settings::values.aspect_ratio.GetValue()), static_cast<float>(height) / width); - if (!ui.action_Single_Window_Mode->isChecked()) { + if (!ui->action_Single_Window_Mode->isChecked()) { render_window->resize(height / aspect_ratio, height); } else { - const bool show_status_bar = ui.action_Show_Status_Bar->isChecked(); + const bool show_status_bar = ui->action_Show_Status_Bar->isChecked(); const auto status_bar_height = show_status_bar ? statusBar()->height() : 0; resize(height / aspect_ratio, height + menuBar()->height() + status_bar_height); } @@ -2647,7 +2648,7 @@ void GMainWindow::OnConfigure() { const bool old_discord_presence = UISettings::values.enable_discord_presence.GetValue(); Settings::SetConfiguringGlobal(true); - ConfigureDialog configure_dialog(this, hotkey_registry, input_subsystem.get(), system); + ConfigureDialog configure_dialog(this, hotkey_registry, input_subsystem.get(), *system); connect(&configure_dialog, &ConfigureDialog::LanguageChanged, this, &GMainWindow::OnLanguageChanged); @@ -2683,7 +2684,7 @@ void GMainWindow::OnConfigure() { Settings::values.disabled_addons.clear(); - config = std::make_unique<Config>(system); + config = std::make_unique<Config>(*system); UISettings::values.reset_to_defaults = false; UISettings::values.game_dirs = std::move(old_game_dirs); @@ -2732,12 +2733,11 @@ void GMainWindow::OnConfigure() { } void GMainWindow::OnConfigureTas() { - const auto& system = Core::System::GetInstance(); ConfigureTasDialog dialog(this); const auto result = dialog.exec(); if (result != QDialog::Accepted && !UISettings::values.configuration_applied) { - Settings::RestoreGlobalState(system.IsPoweredOn()); + Settings::RestoreGlobalState(system->IsPoweredOn()); return; } else if (result == QDialog::Accepted) { dialog.ApplyConfiguration(); @@ -2745,7 +2745,7 @@ void GMainWindow::OnConfigureTas() { } void GMainWindow::OnConfigurePerGame() { - const u64 title_id = system.CurrentProcess()->GetTitleID(); + const u64 title_id = system->CurrentProcess()->GetTitleID(); OpenPerGameConfiguration(title_id, game_path.toStdString()); } @@ -2753,12 +2753,12 @@ void GMainWindow::OpenPerGameConfiguration(u64 title_id, const std::string& file const auto v_file = Core::GetGameFileFromPath(vfs, file_name); Settings::SetConfiguringGlobal(false); - ConfigurePerGame dialog(this, title_id, file_name, system); + ConfigurePerGame dialog(this, title_id, file_name, *system); dialog.LoadFromFile(v_file); const auto result = dialog.exec(); if (result != QDialog::Accepted && !UISettings::values.configuration_applied) { - Settings::RestoreGlobalState(system.IsPoweredOn()); + Settings::RestoreGlobalState(system->IsPoweredOn()); return; } else if (result == QDialog::Accepted) { dialog.ApplyConfiguration(); @@ -2770,7 +2770,7 @@ void GMainWindow::OpenPerGameConfiguration(u64 title_id, const std::string& file } // Do not cause the global config to write local settings into the config file - const bool is_powered_on = system.IsPoweredOn(); + const bool is_powered_on = system->IsPoweredOn(); Settings::RestoreGlobalState(is_powered_on); UISettings::values.configuration_applied = false; @@ -2793,7 +2793,7 @@ void GMainWindow::OnLoadAmiibo() { } void GMainWindow::LoadAmiibo(const QString& filename) { - Service::SM::ServiceManager& sm = system.ServiceManager(); + Service::SM::ServiceManager& sm = system->ServiceManager(); auto nfc = sm.GetService<Service::NFP::Module::Interface>("nfp:user"); if (nfc == nullptr) { return; @@ -2835,8 +2835,8 @@ void GMainWindow::OnAbout() { } void GMainWindow::OnToggleFilterBar() { - game_list->SetFilterVisible(ui.action_Show_Filter_Bar->isChecked()); - if (ui.action_Show_Filter_Bar->isChecked()) { + game_list->SetFilterVisible(ui->action_Show_Filter_Bar->isChecked()); + if (ui->action_Show_Filter_Bar->isChecked()) { game_list->SetFilterFocus(); } else { game_list->ClearFilter(); @@ -2844,7 +2844,7 @@ void GMainWindow::OnToggleFilterBar() { } void GMainWindow::OnCaptureScreenshot() { - const u64 title_id = system.CurrentProcess()->GetTitleID(); + const u64 title_id = system->CurrentProcess()->GetTitleID(); const auto screenshot_path = QString::fromStdString(Common::FS::GetYuzuPathString(Common::FS::YuzuPath::ScreenshotsDir)); const auto date = @@ -2950,8 +2950,8 @@ void GMainWindow::UpdateStatusBar() { tas_label->clear(); } - auto results = system.GetAndResetPerfStats(); - auto& shader_notify = system.GPU().ShaderNotify(); + auto results = system->GetAndResetPerfStats(); + auto& shader_notify = system->GPU().ShaderNotify(); const int shaders_building = shader_notify.ShadersBuilding(); if (shaders_building > 0) { @@ -3013,7 +3013,7 @@ void GMainWindow::UpdateStatusButtons() { } void GMainWindow::UpdateUISettings() { - if (!ui.action_Fullscreen->isChecked()) { + if (!ui->action_Fullscreen->isChecked()) { UISettings::values.geometry = saveGeometry(); UISettings::values.renderwindow_geometry = render_window->saveGeometry(); } @@ -3022,11 +3022,11 @@ void GMainWindow::UpdateUISettings() { UISettings::values.microprofile_geometry = microProfileDialog->saveGeometry(); UISettings::values.microprofile_visible = microProfileDialog->isVisible(); #endif - UISettings::values.single_window_mode = ui.action_Single_Window_Mode->isChecked(); - UISettings::values.fullscreen = ui.action_Fullscreen->isChecked(); - UISettings::values.display_titlebar = ui.action_Display_Dock_Widget_Headers->isChecked(); - UISettings::values.show_filter_bar = ui.action_Show_Filter_Bar->isChecked(); - UISettings::values.show_status_bar = ui.action_Show_Status_Bar->isChecked(); + UISettings::values.single_window_mode = ui->action_Single_Window_Mode->isChecked(); + UISettings::values.fullscreen = ui->action_Fullscreen->isChecked(); + UISettings::values.display_titlebar = ui->action_Display_Dock_Widget_Headers->isChecked(); + UISettings::values.show_filter_bar = ui->action_Show_Filter_Bar->isChecked(); + UISettings::values.show_status_bar = ui->action_Show_Status_Bar->isChecked(); UISettings::values.first_start = false; } @@ -3052,7 +3052,7 @@ void GMainWindow::OnMouseActivity() { } } -void GMainWindow::OnCoreError(Core::System::ResultStatus result, std::string details) { +void GMainWindow::OnCoreError(Core::SystemResultStatus result, std::string details) { QMessageBox::StandardButton answer; QString status_message; const QString common_message = @@ -3067,7 +3067,7 @@ void GMainWindow::OnCoreError(Core::System::ResultStatus result, std::string det "back to the game list? Continuing emulation may result in crashes, corrupted save " "data, or other bugs."); switch (result) { - case Core::System::ResultStatus::ErrorSystemFiles: { + case Core::SystemResultStatus::ErrorSystemFiles: { QString message; if (details.empty()) { message = @@ -3083,7 +3083,7 @@ void GMainWindow::OnCoreError(Core::System::ResultStatus result, std::string det break; } - case Core::System::ResultStatus::ErrorSharedFont: { + case Core::SystemResultStatus::ErrorSharedFont: { const QString message = tr("yuzu was unable to locate the Switch shared fonts. %1").arg(common_message); answer = QMessageBox::question(this, tr("Shared Fonts Not Found"), message, @@ -3112,7 +3112,7 @@ void GMainWindow::OnCoreError(Core::System::ResultStatus result, std::string det if (emu_thread) { ShutdownGame(); - Settings::RestoreGlobalState(system.IsPoweredOn()); + Settings::RestoreGlobalState(system->IsPoweredOn()); UpdateStatusButtons(); } } else { @@ -3154,8 +3154,8 @@ void GMainWindow::OnReinitializeKeys(ReinitializeKeyBehavior behavior) { const auto function = [this, &keys, &pdm] { keys.PopulateFromPartitionData(pdm); - system.GetFileSystemController().CreateFactories(*vfs); - keys.DeriveETicket(pdm, system.GetContentProvider()); + system->GetFileSystemController().CreateFactories(*vfs); + keys.DeriveETicket(pdm, system->GetContentProvider()); }; QString errors; @@ -3197,7 +3197,7 @@ void GMainWindow::OnReinitializeKeys(ReinitializeKeyBehavior behavior) { prog.close(); } - system.GetFileSystemController().CreateFactories(*vfs); + system->GetFileSystemController().CreateFactories(*vfs); if (behavior == ReinitializeKeyBehavior::Warning) { game_list->PopulateAsync(UISettings::values.game_dirs); @@ -3265,7 +3265,7 @@ void GMainWindow::closeEvent(QCloseEvent* event) { if (emu_thread != nullptr) { ShutdownGame(); - Settings::RestoreGlobalState(system.IsPoweredOn()); + Settings::RestoreGlobalState(system->IsPoweredOn()); UpdateStatusButtons(); } @@ -3340,7 +3340,7 @@ bool GMainWindow::ConfirmForceLockedExit() { } void GMainWindow::RequestGameExit() { - auto& sm{system.ServiceManager()}; + auto& sm{system->ServiceManager()}; auto applet_oe = sm.GetService<Service::AM::AppletOE>("appletOE"); auto applet_ae = sm.GetService<Service::AM::AppletAE>("appletAE"); bool has_signalled = false; @@ -3356,7 +3356,7 @@ void GMainWindow::RequestGameExit() { } void GMainWindow::filterBarSetChecked(bool state) { - ui.action_Show_Filter_Bar->setChecked(state); + ui->action_Show_Filter_Bar->setChecked(state); emit(OnToggleFilterBar()); } @@ -3424,17 +3424,17 @@ void GMainWindow::OnLanguageChanged(const QString& locale) { UISettings::values.language = locale; LoadTranslation(); - ui.retranslateUi(this); + ui->retranslateUi(this); UpdateWindowTitle(); if (emulation_running) - ui.action_Start->setText(tr("&Continue")); + ui->action_Start->setText(tr("&Continue")); } void GMainWindow::SetDiscordEnabled([[maybe_unused]] bool state) { #ifdef USE_DISCORD_PRESENCE if (state) { - discord_rpc = std::make_unique<DiscordRPC::DiscordImpl>(system); + discord_rpc = std::make_unique<DiscordRPC::DiscordImpl>(*system); } else { discord_rpc = std::make_unique<DiscordRPC::NullImpl>(); } @@ -3488,8 +3488,7 @@ int main(int argc, char* argv[]) { // generating shaders setlocale(LC_ALL, "C"); - Core::System::InitializeGlobalInstance(); - GMainWindow main_window{Core::System::GetInstance()}; + GMainWindow main_window{}; // After settings have been loaded by GMainWindow, apply the filter main_window.show(); diff --git a/src/yuzu/main.h b/src/yuzu/main.h index e31b3d06b7..aed15a0a09 100644 --- a/src/yuzu/main.h +++ b/src/yuzu/main.h @@ -13,9 +13,7 @@ #include <QTranslator> #include "common/common_types.h" -#include "core/core.h" #include "core/hle/service/acc/profile_manager.h" -#include "ui_main.h" #include "yuzu/compatibility_list.h" #include "yuzu/hotkeys.h" @@ -45,6 +43,11 @@ enum class StartGameType { Global, // Only uses global configuration }; +namespace Core { +enum class SystemResultStatus : u32; +class System; +} // namespace Core + namespace Core::Frontend { struct ControllerParameters; struct InlineAppearParameters; @@ -73,6 +76,10 @@ enum class SwkbdReplyType : u32; enum class WebExitReason : u32; } // namespace Service::AM::Applets +namespace Ui { +class MainWindow; +} + enum class EmulatedDirectoryTarget { NAND, SDMC, @@ -107,7 +114,7 @@ class GMainWindow : public QMainWindow { public: void filterBarSetChecked(bool state); void UpdateUITheme(); - GMainWindow(Core::System& system_); + explicit GMainWindow(); ~GMainWindow() override; bool DropAction(QDropEvent* event); @@ -277,7 +284,7 @@ private slots: void ResetWindowSize900(); void ResetWindowSize1080(); void OnCaptureScreenshot(); - void OnCoreError(Core::System::ResultStatus, std::string); + void OnCoreError(Core::SystemResultStatus, std::string); void OnReinitializeKeys(ReinitializeKeyBehavior behavior); void OnLanguageChanged(const QString& locale); void OnMouseActivity(); @@ -306,13 +313,12 @@ private: void OpenPerGameConfiguration(u64 title_id, const std::string& file_name); QString GetTasStateDescription() const; - Ui::MainWindow ui; + std::unique_ptr<Ui::MainWindow> ui; + std::unique_ptr<Core::System> system; std::unique_ptr<DiscordRPC::DiscordInterface> discord_rpc; std::shared_ptr<InputCommon::InputSubsystem> input_subsystem; - Core::System& system; - GRenderWindow* render_window; GameList* game_list; LoadingScreen* loading_screen; diff --git a/src/yuzu/uisettings.h b/src/yuzu/uisettings.h index 81f741f206..cac19452fe 100644 --- a/src/yuzu/uisettings.h +++ b/src/yuzu/uisettings.h @@ -60,7 +60,7 @@ struct Values { Settings::BasicSetting<bool> confirm_before_closing{true, "confirmClose"}; Settings::BasicSetting<bool> first_start{true, "firstStart"}; Settings::BasicSetting<bool> pause_when_in_background{false, "pauseWhenInBackground"}; - Settings::BasicSetting<bool> hide_mouse{false, "hideInactiveMouse"}; + Settings::BasicSetting<bool> hide_mouse{true, "hideInactiveMouse"}; Settings::BasicSetting<bool> select_user_on_boot{false, "select_user_on_boot"}; diff --git a/src/yuzu_cmd/config.cpp b/src/yuzu_cmd/config.cpp index 8ca20679ad..0b8fde691f 100644 --- a/src/yuzu_cmd/config.cpp +++ b/src/yuzu_cmd/config.cpp @@ -412,8 +412,7 @@ void Config::ReadValues() { const auto custom_rtc_enabled = sdl2_config->GetBoolean("System", "custom_rtc_enabled", false); if (custom_rtc_enabled) { - Settings::values.custom_rtc = - std::chrono::seconds(sdl2_config->GetInteger("System", "custom_rtc", 0)); + Settings::values.custom_rtc = sdl2_config->GetInteger("System", "custom_rtc", 0); } else { Settings::values.custom_rtc = std::nullopt; } diff --git a/src/yuzu_cmd/yuzu.cpp b/src/yuzu_cmd/yuzu.cpp index ba2c993ba0..67587cc546 100644 --- a/src/yuzu_cmd/yuzu.cpp +++ b/src/yuzu_cmd/yuzu.cpp @@ -146,9 +146,8 @@ int main(int argc, char** argv) { return -1; } - Core::System::InitializeGlobalInstance(); - auto& system{Core::System::GetInstance()}; - InputCommon::InputSubsystem input_subsystem; + Core::System system{}; + InputCommon::InputSubsystem input_subsystem{}; // Apply the command line arguments system.ApplySettings(); @@ -167,27 +166,27 @@ int main(int argc, char** argv) { system.SetFilesystem(std::make_shared<FileSys::RealVfsFilesystem>()); system.GetFileSystemController().CreateFactories(*system.GetFilesystem()); - const Core::System::ResultStatus load_result{system.Load(*emu_window, filepath)}; + const Core::SystemResultStatus load_result{system.Load(*emu_window, filepath)}; switch (load_result) { - case Core::System::ResultStatus::ErrorGetLoader: + case Core::SystemResultStatus::ErrorGetLoader: LOG_CRITICAL(Frontend, "Failed to obtain loader for {}!", filepath); return -1; - case Core::System::ResultStatus::ErrorLoader: + case Core::SystemResultStatus::ErrorLoader: LOG_CRITICAL(Frontend, "Failed to load ROM!"); return -1; - case Core::System::ResultStatus::ErrorNotInitialized: + case Core::SystemResultStatus::ErrorNotInitialized: LOG_CRITICAL(Frontend, "CPUCore not initialized"); return -1; - case Core::System::ResultStatus::ErrorVideoCore: + case Core::SystemResultStatus::ErrorVideoCore: LOG_CRITICAL(Frontend, "Failed to initialize VideoCore!"); return -1; - case Core::System::ResultStatus::Success: + case Core::SystemResultStatus::Success: break; // Expected case default: if (static_cast<u32>(load_result) > - static_cast<u32>(Core::System::ResultStatus::ErrorLoader)) { - const u16 loader_id = static_cast<u16>(Core::System::ResultStatus::ErrorLoader); + static_cast<u32>(Core::SystemResultStatus::ErrorLoader)) { + const u16 loader_id = static_cast<u16>(Core::SystemResultStatus::ErrorLoader); const u16 error_id = static_cast<u16>(load_result) - loader_id; LOG_CRITICAL(Frontend, "While attempting to load the ROM requested, an error occurred. Please " |