From f68f720b171a335b8db55faaebd69fbaef31188a Mon Sep 17 00:00:00 2001 From: Hyper <34012267+hyperbx@users.noreply.github.com> Date: Thu, 17 Oct 2024 16:08:53 +0100 Subject: [PATCH] Preliminary mid-asm hook for gracefully exiting the game --- UnleashedRecomp/CMakeLists.txt | 1 + UnleashedRecomp/game.cpp | 12 ++++++++++++ UnleashedRecomp/game.h | 9 +++++++++ UnleashedRecomp/gpu/video.cpp | 1 + UnleashedRecompLib/config/SWA.toml | 5 +++++ 5 files changed, 28 insertions(+) create mode 100644 UnleashedRecomp/game.cpp create mode 100644 UnleashedRecomp/game.h diff --git a/UnleashedRecomp/CMakeLists.txt b/UnleashedRecomp/CMakeLists.txt index da2552e..757a804 100644 --- a/UnleashedRecomp/CMakeLists.txt +++ b/UnleashedRecomp/CMakeLists.txt @@ -46,6 +46,7 @@ set(SWA_UI_CXX_SOURCES ) set(SWA_CXX_SOURCES + "game.cpp" "main.cpp" "misc_impl.cpp" diff --git a/UnleashedRecomp/game.cpp b/UnleashedRecomp/game.cpp new file mode 100644 index 0000000..cedf0d0 --- /dev/null +++ b/UnleashedRecomp/game.cpp @@ -0,0 +1,12 @@ +#include "game.h" + +void Game::Exit() +{ + s_isSignalExit = true; +} + +bool GracefulLoopExitMidAsmHook() +{ + // TODO (Sajid): investigate XAM handle closing causing assertion failure here. + return Game::s_isSignalExit; +} diff --git a/UnleashedRecomp/game.h b/UnleashedRecomp/game.h new file mode 100644 index 0000000..fa8746f --- /dev/null +++ b/UnleashedRecomp/game.h @@ -0,0 +1,9 @@ +#pragma once + +class Game +{ +public: + inline static bool s_isSignalExit = false; + + static void Exit(); +}; diff --git a/UnleashedRecomp/gpu/video.cpp b/UnleashedRecomp/gpu/video.cpp index 8596851..7ffd381 100644 --- a/UnleashedRecomp/gpu/video.cpp +++ b/UnleashedRecomp/gpu/video.cpp @@ -2541,3 +2541,4 @@ GUEST_FUNCTION_STUB(sub_82BEA018); GUEST_FUNCTION_STUB(sub_82BEA7C0); GUEST_FUNCTION_STUB(sub_82BFFF88); // D3DXFilterTexture GUEST_FUNCTION_STUB(sub_82E9EF90); // D3DXFillTexture +GUEST_FUNCTION_STUB(sub_82BD96D0); diff --git a/UnleashedRecompLib/config/SWA.toml b/UnleashedRecompLib/config/SWA.toml index 4bd71fa..432ae41 100644 --- a/UnleashedRecompLib/config/SWA.toml +++ b/UnleashedRecompLib/config/SWA.toml @@ -103,3 +103,8 @@ registers = ["f13"] name = "Primitive2DHalfPixelOffsetMidAsmHook" address = 0x830D213C registers = ["f13"] + +[[midasm_hook]] +name = "GracefulLoopExitMidAsmHook" +address = 0x822C1018 +return_on_true = true \ No newline at end of file