VERY experimental Nintendo Switch 2 emulator
C++
Services: Initialize all state variables at bootup.
bunneie0cb85691a99
diff --git a/src/core/hle/service/apt/apt.cpp b/src/core/hle/service/apt/apt.cppindex 190c5df7a9..98ae80b3a8 100644--- a/src/core/hle/service/apt/apt.cpp+++ b/src/core/hle/service/apt/apt.cpp@@ -28,15 +28,15 @@ namespace APT {static const VAddr SHARED_FONT_VADDR = 0x18000000;/// Handle to shared memory region designated to for shared system font-static Kernel::SharedPtr<Kernel::SharedMemory> shared_font_mem = nullptr;+static Kernel::SharedPtr<Kernel::SharedMemory> shared_font_mem;-static Kernel::SharedPtr<Kernel::Mutex> lock = nullptr;-static Kernel::SharedPtr<Kernel::Event> notification_event = nullptr; ///< APT notification event-static Kernel::SharedPtr<Kernel::Event> start_event = nullptr; ///< APT start event+static Kernel::SharedPtr<Kernel::Mutex> lock;+static Kernel::SharedPtr<Kernel::Event> notification_event; ///< APT notification event+static Kernel::SharedPtr<Kernel::Event> start_event; ///< APT start eventstatic std::vector<u8> shared_font;-static u32 cpu_percent = 0; ///< CPU time available to the running application+static u32 cpu_percent; ///< CPU time available to the running applicationvoid Initialize(Service::Interface* self) {u32* cmd_buff = Kernel::GetCommandBuffer();@@ -309,6 +309,7 @@ void Init() {}lock = Kernel::Mutex::Create(false, "APT_U:Lock");+cpu_percent = 0;// TODO(bunnei): Check if these are created in Initialize or on APT process startup.@@ -317,7 +318,11 @@ void Init() {}void Shutdown() {-+ shared_font.clear();+ shared_font_mem = nullptr;+ lock = nullptr;+ notification_event = nullptr;+ start_event = nullptr;}} // namespace APTdiff --git a/src/core/hle/service/cfg/cfg.cpp b/src/core/hle/service/cfg/cfg.cppindex 6af0352ac6..5eccdecf7d 100644--- a/src/core/hle/service/cfg/cfg.cpp+++ b/src/core/hle/service/cfg/cfg.cpp@@ -207,6 +207,7 @@ void Init() {// Initialize the Username block// TODO(Subv): Initialize this directly in the variable when MSVC supports char16_t string literals+ memset(&CONSOLE_USERNAME_BLOCK, 0, sizeof(CONSOLE_USERNAME_BLOCK));CONSOLE_USERNAME_BLOCK.ng_word = 0;CONSOLE_USERNAME_BLOCK.zero = 0;@@ -219,7 +220,6 @@ void Init() {}void Shutdown() {-}} // namespace CFGdiff --git a/src/core/hle/service/dsp_dsp.cpp b/src/core/hle/service/dsp_dsp.cppindex 4d6c70f4d3..2e759a3e34 100644--- a/src/core/hle/service/dsp_dsp.cpp+++ b/src/core/hle/service/dsp_dsp.cpp@@ -11,7 +11,7 @@namespace DSP_DSP {-static u32 read_pipe_count = 0;+static u32 read_pipe_count;static Kernel::SharedPtr<Kernel::Event> semaphore_event;static Kernel::SharedPtr<Kernel::Event> interrupt_event;diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cppindex 9ca5d13d40..0f30f743a7 100644--- a/src/core/hle/service/hid/hid.cpp+++ b/src/core/hle/service/hid/hid.cpp@@ -20,17 +20,17 @@ namespace HID {static const int MAX_CIRCLEPAD_POS = 0x9C; ///< Max value for a circle pad position// Handle to shared memory region designated to HID_User service-static Kernel::SharedPtr<Kernel::SharedMemory> shared_mem = nullptr;+static Kernel::SharedPtr<Kernel::SharedMemory> shared_mem;// Event handles-static Kernel::SharedPtr<Kernel::Event> event_pad_or_touch_1 = nullptr;-static Kernel::SharedPtr<Kernel::Event> event_pad_or_touch_2 = nullptr;-static Kernel::SharedPtr<Kernel::Event> event_accelerometer = nullptr;-static Kernel::SharedPtr<Kernel::Event> event_gyroscope = nullptr;-static Kernel::SharedPtr<Kernel::Event> event_debug_pad = nullptr;+static Kernel::SharedPtr<Kernel::Event> event_pad_or_touch_1;+static Kernel::SharedPtr<Kernel::Event> event_pad_or_touch_2;+static Kernel::SharedPtr<Kernel::Event> event_accelerometer;+static Kernel::SharedPtr<Kernel::Event> event_gyroscope;+static Kernel::SharedPtr<Kernel::Event> event_debug_pad;-static u32 next_pad_index = 0;-static u32 next_touch_index = 0;+static u32 next_pad_index;+static u32 next_touch_index;// TODO(peachum):// Add a method for setting analog input from joystick device for the circle Pad.@@ -175,6 +175,12 @@ void Init() {}void Shutdown() {+ shared_mem = nullptr;+ event_pad_or_touch_1 = nullptr;+ event_pad_or_touch_2 = nullptr;+ event_accelerometer = nullptr;+ event_gyroscope = nullptr;+ event_debug_pad = nullptr;}} // namespace HIDdiff --git a/src/core/hle/service/ir/ir.cpp b/src/core/hle/service/ir/ir.cppindex 58dfd8e1a4..15ac477efa 100644--- a/src/core/hle/service/ir/ir.cpp+++ b/src/core/hle/service/ir/ir.cpp@@ -15,8 +15,8 @@namespace Service {namespace IR {-static Kernel::SharedPtr<Kernel::Event> handle_event = nullptr;-static Kernel::SharedPtr<Kernel::SharedMemory> shared_memory = nullptr;+static Kernel::SharedPtr<Kernel::Event> handle_event;+static Kernel::SharedPtr<Kernel::SharedMemory> shared_memory;void GetHandles(Service::Interface* self) {u32* cmd_buff = Kernel::GetCommandBuffer();@@ -41,6 +41,8 @@ void Init() {}void Shutdown() {+ shared_memory = nullptr;+ handle_event = nullptr;}} // namespace IRdiff --git a/src/core/hle/service/nwm_uds.cpp b/src/core/hle/service/nwm_uds.cppindex 1cee81ab24..4b06efc3a1 100644--- a/src/core/hle/service/nwm_uds.cpp+++ b/src/core/hle/service/nwm_uds.cpp@@ -11,7 +11,7 @@namespace NWM_UDS {-static Kernel::SharedPtr<Kernel::Event> handle_event = nullptr;+static Kernel::SharedPtr<Kernel::Event> handle_event;/*** NWM_UDS::Shutdown service functiondiff --git a/src/core/hle/service/ptm/ptm.cpp b/src/core/hle/service/ptm/ptm.cppindex 57a301bec3..d44510c1b6 100644--- a/src/core/hle/service/ptm/ptm.cpp+++ b/src/core/hle/service/ptm/ptm.cpp@@ -18,9 +18,9 @@ static const GameCoin default_game_coin = { 0x4F00, 42, 0, 0, 0, 2014, 12, 29 };/// Id of the SharedExtData archive used by the PTM processstatic const std::vector<u8> ptm_shared_extdata_id = {0, 0, 0, 0, 0x0B, 0, 0, 0xF0, 0, 0, 0, 0};-static bool shell_open = true;+static bool shell_open;-static bool battery_is_charging = true;+static bool battery_is_charging;u32 GetAdapterState() {// TODO(purpasmart96): This function is only a stub,@@ -43,6 +43,9 @@ void Init() {AddService(new PTM_Sysm_Interface);AddService(new PTM_U_Interface);+ shell_open = true;+ battery_is_charging = true;+// Open the SharedExtSaveData archive 0xF000000B and create the gamecoin.dat file if it doesn't existFileSys::Path archive_path(ptm_shared_extdata_id);auto archive_result = Service::FS::OpenArchive(Service::FS::ArchiveIdCode::SharedExtSaveData, archive_path);diff --git a/src/core/hle/service/y2r_u.cpp b/src/core/hle/service/y2r_u.cppindex 6607965e1f..33ecf64a26 100644--- a/src/core/hle/service/y2r_u.cpp+++ b/src/core/hle/service/y2r_u.cpp@@ -11,7 +11,7 @@namespace Y2R_U {-static Kernel::SharedPtr<Kernel::Event> completion_event = 0;+static Kernel::SharedPtr<Kernel::Event> completion_event;/*** Y2R_U::IsBusyConversion service function