From 8df502a6883c231c1318f7cb3b29509bed12ddd0 Mon Sep 17 00:00:00 2001 From: xperia64 Date: Tue, 26 Jan 2021 20:27:52 +0000 Subject: [PATCH] Implement APT command 0x0103 (#5478) * WIP implement apt 0x0103 * Update src/core/hle/service/apt/apt.cpp Co-authored-by: Pengfei Zhu * Names Co-authored-by: Pengfei Zhu --- src/core/hle/service/apt/apt.cpp | 11 +++++++++++ src/core/hle/service/apt/apt.h | 8 ++++++++ src/core/hle/service/apt/apt_a.cpp | 1 + src/core/hle/service/apt/apt_s.cpp | 1 + src/core/hle/service/apt/apt_u.cpp | 1 + 5 files changed, 22 insertions(+) diff --git a/src/core/hle/service/apt/apt.cpp b/src/core/hle/service/apt/apt.cpp index a22926a9c..c52aecff4 100644 --- a/src/core/hle/service/apt/apt.cpp +++ b/src/core/hle/service/apt/apt.cpp @@ -28,6 +28,7 @@ #include "core/hle/service/service.h" #include "core/hw/aes/ccm.h" #include "core/hw/aes/key.h" +#include "core/settings.h" SERVICE_CONSTRUCT_IMPL(Service::APT::Module) @@ -1007,6 +1008,16 @@ void Module::APTInterface::CheckNew3DS(Kernel::HLERequestContext& ctx) { LOG_WARNING(Service_APT, "(STUBBED) called"); } +void Module::APTInterface::Unknown0x0103(Kernel::HLERequestContext& ctx) { + IPC::RequestParser rp(ctx, 0x103, 0, 0); // 0x01030000 + IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); + + rb.Push(RESULT_SUCCESS); + rb.Push(Settings::values.is_new_3ds ? 2 : 1); + + LOG_WARNING(Service_APT, "(STUBBED) called"); +} + void Module::APTInterface::IsTitleAllowed(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp(ctx, 0x105, 4, 0); // 0x01050100 const u64 program_id = rp.Pop(); diff --git a/src/core/hle/service/apt/apt.h b/src/core/hle/service/apt/apt.h index abf2fc9ce..851136ad0 100644 --- a/src/core/hle/service/apt/apt.h +++ b/src/core/hle/service/apt/apt.h @@ -690,6 +690,14 @@ public: */ void CheckNew3DS(Kernel::HLERequestContext& ctx); + /** + * APT::Unknown0x0103 service function. Determines whether Smash 4 allows C-Stick + * Outputs: + * 1: Result code, 0 on success otherwise error code + * 2: u8 output: 2 = New3DS+valid/initialized (in Smash 4), 1 = Old3DS or invalid + */ + void Unknown0x0103(Kernel::HLERequestContext& ctx); + /** * APT::IsTitleAllowed service function * Inputs: diff --git a/src/core/hle/service/apt/apt_a.cpp b/src/core/hle/service/apt/apt_a.cpp index 4f3a5f3d0..87e454f1c 100644 --- a/src/core/hle/service/apt/apt_a.cpp +++ b/src/core/hle/service/apt/apt_a.cpp @@ -99,6 +99,7 @@ APT_A::APT_A(std::shared_ptr apt) {0x00580002, nullptr, "GetProgramID"}, {0x01010000, &APT_A::CheckNew3DSApp, "CheckNew3DSApp"}, {0x01020000, &APT_A::CheckNew3DS, "CheckNew3DS"}, + {0x01030000, &APT_A::Unknown0x0103, "Unknown0x0103"}, {0x01040000, nullptr, "IsStandardMemoryLayout"}, {0x01050100, &APT_A::IsTitleAllowed, "IsTitleAllowed"}, }; diff --git a/src/core/hle/service/apt/apt_s.cpp b/src/core/hle/service/apt/apt_s.cpp index 20359c2ae..732b55a23 100644 --- a/src/core/hle/service/apt/apt_s.cpp +++ b/src/core/hle/service/apt/apt_s.cpp @@ -99,6 +99,7 @@ APT_S::APT_S(std::shared_ptr apt) {0x00580002, nullptr, "GetProgramID"}, {0x01010000, &APT_S::CheckNew3DSApp, "CheckNew3DSApp"}, {0x01020000, &APT_S::CheckNew3DS, "CheckNew3DS"}, + {0x01030000, &APT_S::Unknown0x0103, "Unknown0x0103"}, {0x01040000, nullptr, "IsStandardMemoryLayout"}, {0x01050100, &APT_S::IsTitleAllowed, "IsTitleAllowed"}, }; diff --git a/src/core/hle/service/apt/apt_u.cpp b/src/core/hle/service/apt/apt_u.cpp index 43b821c39..ec1dbe291 100644 --- a/src/core/hle/service/apt/apt_u.cpp +++ b/src/core/hle/service/apt/apt_u.cpp @@ -98,6 +98,7 @@ APT_U::APT_U(std::shared_ptr apt) {0x00580002, nullptr, "GetProgramID"}, {0x01010000, &APT_U::CheckNew3DSApp, "CheckNew3DSApp"}, {0x01020000, &APT_U::CheckNew3DS, "CheckNew3DS"}, + {0x01030000, &APT_U::Unknown0x0103, "Unknown0x0103"}, }; RegisterHandlers(functions); }