From 7d5da9eaeb47c12955d7ac823028e01b4a2df9fd Mon Sep 17 00:00:00 2001 From: PabloMK7 Date: Sun, 8 Mar 2026 18:41:31 +0100 Subject: [PATCH] core: Fix application jump parameters (#1845) --- src/core/hle/service/apt/applet_manager.cpp | 2 ++ src/core/hle/service/apt/applet_manager.h | 19 ++++++++++---- src/core/hle/service/apt/apt.cpp | 29 ++++++++++++--------- 3 files changed, 32 insertions(+), 18 deletions(-) diff --git a/src/core/hle/service/apt/applet_manager.cpp b/src/core/hle/service/apt/applet_manager.cpp index 1dcbb430e..b459fdd1f 100644 --- a/src/core/hle/service/apt/applet_manager.cpp +++ b/src/core/hle/service/apt/applet_manager.cpp @@ -1456,6 +1456,8 @@ Result AppletManager::PrepareToStartApplication(u64 title_id, FS::MediaType medi capture_buffer_info.reset(); + app_jump_parameters.Invalidate(); + return ResultSuccess; } diff --git a/src/core/hle/service/apt/applet_manager.h b/src/core/hle/service/apt/applet_manager.h index 3924ec510..0def102d3 100644 --- a/src/core/hle/service/apt/applet_manager.h +++ b/src/core/hle/service/apt/applet_manager.h @@ -185,12 +185,21 @@ private: using SysMenuArg = std::array; struct ApplicationJumpParameters { - u64 next_title_id; - FS::MediaType next_media_type; - ApplicationJumpFlags flags; + u64 next_title_id = ~0ULL; + FS::MediaType next_media_type{}; + ApplicationJumpFlags flags{}; - u64 current_title_id; - FS::MediaType current_media_type; + u64 current_title_id = ~0ULL; + FS::MediaType current_media_type{}; + + bool Valid() const { + return next_title_id != ~0ULL && current_title_id != ~0ULL; + } + + void Invalidate() { + next_title_id = ~0ULL; + current_title_id = ~0ULL; + } private: template diff --git a/src/core/hle/service/apt/apt.cpp b/src/core/hle/service/apt/apt.cpp index 7b2dfeb19..50bb765a2 100644 --- a/src/core/hle/service/apt/apt.cpp +++ b/src/core/hle/service/apt/apt.cpp @@ -1251,23 +1251,26 @@ void Module::APTInterface::GetStartupArgument(Kernel::HLERequestContext& ctx) { bool exists = false; if (auto arg = apt->applet_manager->ReceiveDeliverArg()) { - param = std::move(arg->param); - // TODO: This is a complete guess based on observations. It is unknown how the OtherMedia // type is handled and how it interacts with the OtherApp type, and it is unknown if // this (checking the jump parameters) is indeed the way the 3DS checks the types. const auto& jump_parameters = apt->applet_manager->GetApplicationJumpParameters(); - switch (startup_argument_type) { - case StartupArgumentType::OtherApp: - exists = jump_parameters.current_title_id != jump_parameters.next_title_id && - jump_parameters.current_media_type == jump_parameters.next_media_type; - break; - case StartupArgumentType::Restart: - exists = jump_parameters.current_title_id == jump_parameters.next_title_id; - break; - case StartupArgumentType::OtherMedia: - exists = jump_parameters.current_media_type != jump_parameters.next_media_type; - break; + + if (jump_parameters.Valid()) { + param = std::move(arg->param); + + switch (startup_argument_type) { + case StartupArgumentType::OtherApp: + exists = jump_parameters.current_title_id != jump_parameters.next_title_id && + jump_parameters.current_media_type == jump_parameters.next_media_type; + break; + case StartupArgumentType::Restart: + exists = jump_parameters.current_title_id == jump_parameters.next_title_id; + break; + case StartupArgumentType::OtherMedia: + exists = jump_parameters.current_media_type != jump_parameters.next_media_type; + break; + } } }