diff --git a/src/core/hle/service/apt/apt.cpp b/src/core/hle/service/apt/apt.cpp index b364beed9..3dd46c08c 100644 --- a/src/core/hle/service/apt/apt.cpp +++ b/src/core/hle/service/apt/apt.cpp @@ -19,6 +19,8 @@ #include "core/hle/kernel/shared_memory.h" #include "core/hle/kernel/thread.h" +#include "core/hle/service/ptm/ptm.h" + namespace Service { namespace APT { @@ -327,6 +329,23 @@ void GetAppCpuTimeLimit(Service::Interface* self) { LOG_WARNING(Service_APT, "(STUBBED) called value=%u", value); } +void Unknown_0x01010000(Service::Interface* self){ + u32* cmd_buff = Kernel::GetCommandBuffer(); + + cmd_buff[1] = RESULT_SUCCESS.raw; + + // When a certain NS state field (internal NS state in .data/.bss.) is non-zero, the output value is zero + // If/Else is to indicate that a check should occur here. + if (false){ + cmd_buff[2] = 0; + } + else{ + cmd_buff[2] = PTM::CheckNew3DS(); + } + + LOG_WARNING(Service_APT, "(STUBBED) does not check internal NS state field"); +} + void PrepareToStartLibraryApplet(Service::Interface* self) { u32* cmd_buff = Kernel::GetCommandBuffer(); AppletId applet_id = static_cast(cmd_buff[1]); diff --git a/src/core/hle/service/apt/apt.h b/src/core/hle/service/apt/apt.h index 72972d05b..f8d19ded6 100644 --- a/src/core/hle/service/apt/apt.h +++ b/src/core/hle/service/apt/apt.h @@ -299,6 +299,15 @@ void PrepareToStartLibraryApplet(Service::Interface* self); */ void StartLibraryApplet(Service::Interface* self); +/** +* From 3Ds Brew: +* This writes an output u8 to cmdreply indexword[2]. +* This uses PTMSYSM:CheckNew3DS. +* When a certain NS state field (internal NS state in .data/.bss.) is non-zero, the output value is zero, otherwise the output is from PTMSYSM:CheckNew3DS. +* Normally this NS state field is zero, however this state field is set to 1 when APT:PrepareToStartApplication is used with flags bit8 is set. +*/ +void Unknown_0x01010000(Service::Interface* self); + /// Initialize the APT service void Init(); diff --git a/src/core/hle/service/apt/apt_a.cpp b/src/core/hle/service/apt/apt_a.cpp index 88de339f9..db900ed88 100644 --- a/src/core/hle/service/apt/apt_a.cpp +++ b/src/core/hle/service/apt/apt_a.cpp @@ -28,6 +28,7 @@ const Interface::FunctionInfo FunctionTable[] = { {0x00440000, GetSharedFont, "GetSharedFont?"}, {0x004B00C2, AppletUtility, "AppletUtility?"}, {0x00550040, nullptr, "WriteInputToNsState?"}, + {0x01010000, Unknown_0x01010000, "Unknown_0x01010000"}, }; APT_A_Interface::APT_A_Interface() { diff --git a/src/core/hle/service/apt/apt_s.cpp b/src/core/hle/service/apt/apt_s.cpp index 396d1f04a..99acec9a6 100644 --- a/src/core/hle/service/apt/apt_s.cpp +++ b/src/core/hle/service/apt/apt_s.cpp @@ -91,6 +91,7 @@ const Interface::FunctionInfo FunctionTable[] = { {0x004E0000, nullptr, "HardwareResetAsync"}, {0x004F0080, nullptr, "SetApplicationCpuTimeLimit"}, {0x00500040, nullptr, "GetApplicationCpuTimeLimit"}, + {0x01010000, Unknown_0x01010000, "Unknown_0x01010000" }, }; APT_S_Interface::APT_S_Interface() { diff --git a/src/core/hle/service/apt/apt_u.cpp b/src/core/hle/service/apt/apt_u.cpp index b724cd72b..999071092 100644 --- a/src/core/hle/service/apt/apt_u.cpp +++ b/src/core/hle/service/apt/apt_u.cpp @@ -92,6 +92,7 @@ const Interface::FunctionInfo FunctionTable[] = { {0x004E0000, nullptr, "HardwareResetAsync"}, {0x004F0080, SetAppCpuTimeLimit, "SetAppCpuTimeLimit"}, {0x00500040, GetAppCpuTimeLimit, "GetAppCpuTimeLimit"}, + {0x01010000, Unknown_0x01010000, "Unknown_0x01010000"}, }; APT_U_Interface::APT_U_Interface() { diff --git a/src/core/hle/service/ptm/ptm.cpp b/src/core/hle/service/ptm/ptm.cpp index 2c7d49c9f..740071f42 100644 --- a/src/core/hle/service/ptm/ptm.cpp +++ b/src/core/hle/service/ptm/ptm.cpp @@ -77,6 +77,10 @@ void IsLegacyPowerOff(Service::Interface* self) { LOG_WARNING(Service_PTM, "(STUBBED) called"); } +u8 CheckNew3DS(){ + return static_cast(PhysicalVersion::Old3DS); +} + void Init() { AddService(new PTM_Play_Interface); AddService(new PTM_Sysm_Interface); diff --git a/src/core/hle/service/ptm/ptm.h b/src/core/hle/service/ptm/ptm.h index b690003cb..26203d790 100644 --- a/src/core/hle/service/ptm/ptm.h +++ b/src/core/hle/service/ptm/ptm.h @@ -79,6 +79,12 @@ void GetBatteryChargeState(Interface* self); */ void IsLegacyPowerOff(Interface* self); +/** +* Checks the physical version of the 3Ds +* @returns The physical version of the 3Ds +*/ +u8 CheckNew3DS(void); + /// Initialize the PTM service void Init(); diff --git a/src/core/hle/service/ptm/ptm_sysm.cpp b/src/core/hle/service/ptm/ptm_sysm.cpp index 655658f3b..8b433cd18 100644 --- a/src/core/hle/service/ptm/ptm_sysm.cpp +++ b/src/core/hle/service/ptm/ptm_sysm.cpp @@ -5,10 +5,24 @@ #include "core/hle/hle.h" #include "core/hle/service/ptm/ptm.h" #include "core/hle/service/ptm/ptm_sysm.h" +#include "core/hle/service/ptm/ptm.h" namespace Service { namespace PTM { +/** +* Returns whether the system is an Old3DS, or a New3DS +* Outputs: +* 1: Result code, 0 on success, otherwise error code +* 2: Result of function, 0 for Old3DS, or 1 for New3DS +*/ +void CheckNew3DS(Service::Interface* self){ + u32* cmd_buff = Kernel::GetCommandBuffer(); + + cmd_buff[1] = RESULT_SUCCESS.raw; + cmd_buff[2] = PTM::CheckNew3DS(); +} + const Interface::FunctionInfo FunctionTable[] = { {0x040100C0, nullptr, "SetRtcAlarmEx"}, {0x04020042, nullptr, "ReplySleepQuery"}, @@ -19,7 +33,7 @@ const Interface::FunctionInfo FunctionTable[] = { {0x040700C0, nullptr, "ShutdownAsync"}, {0x04080000, nullptr, "Awake"}, {0x04090080, nullptr, "RebootAsync"}, - {0x040A0000, nullptr, "CheckNew3DS"}, + {0x040A0000, CheckNew3DS, "CheckNew3DS"}, {0x08010640, nullptr, "SetInfoLEDPattern"}, {0x08020040, nullptr, "SetInfoLEDPatternHeader"}, {0x08030000, nullptr, "GetInfoLEDStatus"}, diff --git a/src/core/hle/service/ptm/ptm_sysm.h b/src/core/hle/service/ptm/ptm_sysm.h index e37f20546..ad28186c3 100644 --- a/src/core/hle/service/ptm/ptm_sysm.h +++ b/src/core/hle/service/ptm/ptm_sysm.h @@ -9,6 +9,12 @@ namespace Service { namespace PTM { +/// Physical version of the 3DS +enum class PhysicalVersion : u8 { + Old3DS = 0, + New3DS = 1, +}; + class PTM_Sysm_Interface : public Interface { public: PTM_Sysm_Interface();