diff --git a/UnleashedRecomp/CMakeLists.txt b/UnleashedRecomp/CMakeLists.txt index 1c497dc3..6d38589c 100644 --- a/UnleashedRecomp/CMakeLists.txt +++ b/UnleashedRecomp/CMakeLists.txt @@ -154,8 +154,9 @@ set(SWA_PATCHES_CXX_SOURCES "patches/ui/frontend_listener.cpp" "patches/aspect_ratio_patches.cpp" "patches/audio_patches.cpp" - "patches/camera_patches.cpp" - "patches/fps_patches.cpp" + "patches/camera_patches.cpp" + "patches/CGameModeStageTitle_patches.cpp" + "patches/fps_patches.cpp" "patches/input_patches.cpp" "patches/inspire_patches.cpp" "patches/misc_patches.cpp" @@ -197,22 +198,22 @@ set(SWA_INSTALL_CXX_SOURCES set(SWA_USER_CXX_SOURCES "user/achievement_data.cpp" "user/config.cpp" -) - -set(SWA_MOD_CXX_SOURCES - "mod/mod_loader.cpp" +) + +set(SWA_MOD_CXX_SOURCES + "mod/mod_loader.cpp" ) set(SWA_THIRDPARTY_SOURCES "${SWA_THIRDPARTY_ROOT}/imgui/backends/imgui_impl_sdl2.cpp" - "${SWA_THIRDPARTY_ROOT}/imgui/imgui.cpp" + "${SWA_THIRDPARTY_ROOT}/imgui/imgui.cpp" "${SWA_THIRDPARTY_ROOT}/imgui/imgui_demo.cpp" "${SWA_THIRDPARTY_ROOT}/imgui/imgui_draw.cpp" "${SWA_THIRDPARTY_ROOT}/imgui/imgui_tables.cpp" "${SWA_THIRDPARTY_ROOT}/imgui/imgui_widgets.cpp" - "${SWA_THIRDPARTY_ROOT}/implot/implot.cpp" - "${SWA_THIRDPARTY_ROOT}/implot/implot_demo.cpp" - "${SWA_THIRDPARTY_ROOT}/implot/implot_items.cpp" + "${SWA_THIRDPARTY_ROOT}/implot/implot.cpp" + "${SWA_THIRDPARTY_ROOT}/implot/implot_demo.cpp" + "${SWA_THIRDPARTY_ROOT}/implot/implot_items.cpp" "${SWA_THIRDPARTY_ROOT}/libmspack/libmspack/mspack/lzxd.c" "${SWA_THIRDPARTY_ROOT}/tiny-AES-c/aes.c" "${SWA_TOOLS_ROOT}/ShaderRecomp/thirdparty/smol-v/source/smolv.cpp" @@ -221,7 +222,7 @@ set(SWA_THIRDPARTY_SOURCES set(SWA_THIRDPARTY_INCLUDES "${SWA_THIRDPARTY_ROOT}/concurrentqueue" "${SWA_THIRDPARTY_ROOT}/ddspp" - "${SWA_THIRDPARTY_ROOT}/imgui" + "${SWA_THIRDPARTY_ROOT}/imgui" "${SWA_THIRDPARTY_ROOT}/implot" "${SWA_THIRDPARTY_ROOT}/libmspack/libmspack/mspack" "${SWA_THIRDPARTY_ROOT}/magic_enum/include" @@ -248,7 +249,7 @@ set(SWA_CXX_SOURCES "exports.cpp" "main.cpp" "misc_impl.cpp" - "stdafx.cpp" + "stdafx.cpp" "version.cpp" ${SWA_KERNEL_CXX_SOURCES} @@ -261,7 +262,7 @@ set(SWA_CXX_SOURCES ${SWA_PATCHES_CXX_SOURCES} ${SWA_UI_CXX_SOURCES} ${SWA_INSTALL_CXX_SOURCES} - ${SWA_USER_CXX_SOURCES} + ${SWA_USER_CXX_SOURCES} ${SWA_MOD_CXX_SOURCES} ${SWA_THIRDPARTY_SOURCES} ) @@ -275,7 +276,7 @@ else() add_executable(UnleashedRecomp ${SWA_CXX_SOURCES}) endif() -set_target_properties(UnleashedRecomp PROPERTIES OUTPUT_NAME ${TARGET_NAME}) +set_target_properties(UnleashedRecomp PROPERTIES OUTPUT_NAME ${TARGET_NAME}) if (SWA_FLATPAK) target_compile_definitions(UnleashedRecomp PRIVATE "GAME_INSTALL_DIRECTORY=\"/var/data\"") @@ -381,8 +382,8 @@ function(compile_pixel_shader FILE_PATH) endfunction() compile_vertex_shader(copy_vs) -compile_pixel_shader(csd_filter_ps) -compile_vertex_shader(csd_no_tex_vs) +compile_pixel_shader(csd_filter_ps) +compile_vertex_shader(csd_no_tex_vs) compile_vertex_shader(csd_vs) compile_pixel_shader(enhanced_motion_blur_ps) compile_pixel_shader(gaussian_blur_3x3) @@ -426,21 +427,21 @@ generate_aggregate_header( "${CMAKE_CURRENT_SOURCE_DIR}/api" "${CMAKE_CURRENT_SOURCE_DIR}/api/SWA.h" ) - -# Only show build type if not Release. -set(IS_BUILD_TYPE_IN_VER_STRING 0) -if (NOT ${CMAKE_BUILD_TYPE} MATCHES "Release") - set(IS_BUILD_TYPE_IN_VER_STRING 1) -endif() - -include("version.cmake") -GenerateVersionSources( - OUTPUT_DIR "${PROJECT_SOURCE_DIR}" - VERSION_TXT "${PROJECT_SOURCE_DIR}/res/version.txt" - H_TEMPLATE "${PROJECT_SOURCE_DIR}/res/version.h.template" - CXX_TEMPLATE "${PROJECT_SOURCE_DIR}/res/version.cpp.template" - BUILD_TYPE ${CMAKE_BUILD_TYPE} - IS_BUILD_TYPE_IN_VER_STRING ${IS_BUILD_TYPE_IN_VER_STRING} + +# Only show build type if not Release. +set(IS_BUILD_TYPE_IN_VER_STRING 0) +if (NOT ${CMAKE_BUILD_TYPE} MATCHES "Release") + set(IS_BUILD_TYPE_IN_VER_STRING 1) +endif() + +include("version.cmake") +GenerateVersionSources( + OUTPUT_DIR "${PROJECT_SOURCE_DIR}" + VERSION_TXT "${PROJECT_SOURCE_DIR}/res/version.txt" + H_TEMPLATE "${PROJECT_SOURCE_DIR}/res/version.h.template" + CXX_TEMPLATE "${PROJECT_SOURCE_DIR}/res/version.cpp.template" + BUILD_TYPE ${CMAKE_BUILD_TYPE} + IS_BUILD_TYPE_IN_VER_STRING ${IS_BUILD_TYPE_IN_VER_STRING} IS_GIT_REPO 1 ) diff --git a/UnleashedRecomp/api/Hedgehog/Universe/Engine/hhStateMachineBase.h b/UnleashedRecomp/api/Hedgehog/Universe/Engine/hhStateMachineBase.h new file mode 100644 index 00000000..269cf865 --- /dev/null +++ b/UnleashedRecomp/api/Hedgehog/Universe/Engine/hhStateMachineBase.h @@ -0,0 +1,32 @@ +#pragma once + +#include +#include +#include +#include + +namespace Hedgehog::Universe +{ + class CStateMachineBase : public IStateMachineMessageReceiver, public Base::CObject + { + public: + class CStateBase : public IMessageProcess + { + public: + SWA_INSERT_PADDING(0x08); + xpointer m_pContext; + xpointer m_pStateMachine; + be m_Time; + SWA_INSERT_PADDING(0x4C); + + void* GetContextBase() const; + + template + T* GetContextBase() const; + }; + + SWA_INSERT_PADDING(0x60); + }; +} + +#include diff --git a/UnleashedRecomp/api/Hedgehog/Universe/Engine/hhStateMachineBase.inl b/UnleashedRecomp/api/Hedgehog/Universe/Engine/hhStateMachineBase.inl new file mode 100644 index 00000000..0750b37f --- /dev/null +++ b/UnleashedRecomp/api/Hedgehog/Universe/Engine/hhStateMachineBase.inl @@ -0,0 +1,13 @@ +namespace Hedgehog::Universe +{ + inline void* CStateMachineBase::CStateBase::GetContextBase() const + { + return m_pContext; + } + + template + inline T* CStateMachineBase::CStateBase::GetContextBase() const + { + return (T*)m_pContext.get(); + } +} diff --git a/UnleashedRecomp/api/Hedgehog/Universe/Engine/hhStateMachineMessageReceiver.h b/UnleashedRecomp/api/Hedgehog/Universe/Engine/hhStateMachineMessageReceiver.h new file mode 100644 index 00000000..f75ce5ee --- /dev/null +++ b/UnleashedRecomp/api/Hedgehog/Universe/Engine/hhStateMachineMessageReceiver.h @@ -0,0 +1,12 @@ +#pragma once + +#include + +namespace Hedgehog::Universe +{ + class IStateMachineMessageReceiver + { + public: + IStateMachineMessageReceiver(const swa_null_ctor&) {} + }; +} diff --git a/UnleashedRecomp/api/SWA.h b/UnleashedRecomp/api/SWA.h index 20c3ea90..e2a846e1 100644 --- a/UnleashedRecomp/api/SWA.h +++ b/UnleashedRecomp/api/SWA.h @@ -47,6 +47,8 @@ #include "Hedgehog/Sparkle/hhParticleMaterial.h" #include "Hedgehog/Universe/Engine/hhMessageActor.h" #include "Hedgehog/Universe/Engine/hhMessageProcess.h" +#include "Hedgehog/Universe/Engine/hhStateMachineBase.h" +#include "Hedgehog/Universe/Engine/hhStateMachineMessageReceiver.h" #include "Hedgehog/Universe/Engine/hhUpdateInfo.h" #include "Hedgehog/Universe/Engine/hhUpdateUnit.h" #include "Hedgehog/Universe/Thread/hhParallelJob.h" @@ -91,8 +93,10 @@ #include "SWA/System/GameMode/GameMode.h" #include "SWA/System/GameMode/GameModeStage.h" #include "SWA/System/GameMode/GameModeStageMovie.h" +#include "SWA/System/GameMode/GameModeStageTitle.h" #include "SWA/System/GameMode/Title/TitleMenu.h" #include "SWA/System/GameMode/Title/TitleStateBase.h" +#include "SWA/System/GameMode/Title/TitleStateIntro.h" #include "SWA/System/GameObject.h" #include "SWA/System/GameParameter.h" #include "SWA/System/GammaController.h" diff --git a/UnleashedRecomp/api/SWA/System/GameMode/GameMode.h b/UnleashedRecomp/api/SWA/System/GameMode/GameMode.h index 5b6c35dc..8c64abcf 100644 --- a/UnleashedRecomp/api/SWA/System/GameMode/GameMode.h +++ b/UnleashedRecomp/api/SWA/System/GameMode/GameMode.h @@ -4,10 +4,9 @@ namespace SWA { - class CGameMode // : Hedgehog::Universe::TStateMachine::TState + class CGameMode : public Hedgehog::Universe::CStateMachineBase::CStateBase { public: - SWA_INSERT_PADDING(0x60); // base SWA_INSERT_PADDING(0x08); }; } diff --git a/UnleashedRecomp/api/SWA/System/GameMode/GameModeStageTitle.h b/UnleashedRecomp/api/SWA/System/GameMode/GameModeStageTitle.h new file mode 100644 index 00000000..b2b6f845 --- /dev/null +++ b/UnleashedRecomp/api/SWA/System/GameMode/GameModeStageTitle.h @@ -0,0 +1,14 @@ +#pragma once + +#include + +namespace SWA +{ + class CGameModeStageTitle : public CGameModeStage + { + public: + SWA_INSERT_PADDING(0x0E); + bool m_IsPlayingAdvertiseMovie; + be m_AdvertiseMovieWaitTime; + }; +} diff --git a/UnleashedRecomp/api/SWA/System/GameMode/Title/TitleStateBase.h b/UnleashedRecomp/api/SWA/System/GameMode/Title/TitleStateBase.h index 6782f3b5..da38b6c9 100644 --- a/UnleashedRecomp/api/SWA/System/GameMode/Title/TitleStateBase.h +++ b/UnleashedRecomp/api/SWA/System/GameMode/Title/TitleStateBase.h @@ -4,19 +4,14 @@ namespace SWA { - class CTitleStateBase // : Hedgehog::Universe::TStateMachine::TState + class CTitleStateBase : public Hedgehog::Universe::CStateMachineBase::CStateBase { public: - class CMember + class CTitleStateContext { public: SWA_INSERT_PADDING(0x1E8); xpointer m_pTitleMenu; }; - - SWA_INSERT_PADDING(0x08); - xpointer m_pMember; - SWA_INSERT_PADDING(0x5C); - be m_State; }; } diff --git a/UnleashedRecomp/api/SWA/System/GameMode/Title/TitleStateIntro.h b/UnleashedRecomp/api/SWA/System/GameMode/Title/TitleStateIntro.h new file mode 100644 index 00000000..618a0783 --- /dev/null +++ b/UnleashedRecomp/api/SWA/System/GameMode/Title/TitleStateIntro.h @@ -0,0 +1,8 @@ +#pragma once + +#include + +namespace SWA +{ + class CTitleStateIntro : public CTitleStateBase {}; +} diff --git a/UnleashedRecomp/patches/CGameModeStageTitle_patches.cpp b/UnleashedRecomp/patches/CGameModeStageTitle_patches.cpp new file mode 100644 index 00000000..15fdb3b1 --- /dev/null +++ b/UnleashedRecomp/patches/CGameModeStageTitle_patches.cpp @@ -0,0 +1,14 @@ +#include +#include + +// SWA::CGameModeStageTitle::Update +PPC_FUNC_IMPL(__imp__sub_825518B8); +PPC_FUNC(sub_825518B8) +{ + auto pGameModeStageTitle = (SWA::CGameModeStageTitle*)g_memory.Translate(ctx.r3.u32); + + __imp__sub_825518B8(ctx, base); + + if (g_quitMessageOpen) + pGameModeStageTitle->m_AdvertiseMovieWaitTime = 0; +} diff --git a/UnleashedRecomp/patches/ui/CTitleStateIntro_patches.cpp b/UnleashedRecomp/patches/ui/CTitleStateIntro_patches.cpp index 4b7f8b65..dfc6db15 100644 --- a/UnleashedRecomp/patches/ui/CTitleStateIntro_patches.cpp +++ b/UnleashedRecomp/patches/ui/CTitleStateIntro_patches.cpp @@ -1,3 +1,4 @@ +#include "CTitleStateIntro_patches.h" #include #include #include diff --git a/UnleashedRecomp/patches/ui/CTitleStateIntro_patches.h b/UnleashedRecomp/patches/ui/CTitleStateIntro_patches.h new file mode 100644 index 00000000..74a123ac --- /dev/null +++ b/UnleashedRecomp/patches/ui/CTitleStateIntro_patches.h @@ -0,0 +1,3 @@ +#pragma once + +extern bool g_quitMessageOpen; diff --git a/UnleashedRecomp/patches/ui/CTitleStateMenu_patches.cpp b/UnleashedRecomp/patches/ui/CTitleStateMenu_patches.cpp index aea4b65d..c4050a7e 100644 --- a/UnleashedRecomp/patches/ui/CTitleStateMenu_patches.cpp +++ b/UnleashedRecomp/patches/ui/CTitleStateMenu_patches.cpp @@ -50,15 +50,18 @@ PPC_FUNC_IMPL(__imp__sub_825882B8); PPC_FUNC(sub_825882B8) { auto pTitleState = (SWA::CTitleStateBase*)g_memory.Translate(ctx.r3.u32); + auto pInputState = SWA::CInputState::GetInstance(); auto& pPadState = pInputState->GetPadState(); auto isAccepted = pPadState.IsTapped(SWA::eKeyState_A) || pPadState.IsTapped(SWA::eKeyState_Start); - auto isOptionsIndex = pTitleState->m_pMember->m_pTitleMenu->m_CursorIndex == 2; - auto isInstallIndex = pTitleState->m_pMember->m_pTitleMenu->m_CursorIndex == 3; + + auto pContext = pTitleState->GetContextBase(); + auto isOptionsIndex = pContext->m_pTitleMenu->m_CursorIndex == 2; + auto isInstallIndex = pContext->m_pTitleMenu->m_CursorIndex == 3; // Always default to New Game with corrupted save data. - if (App::s_isSaveDataCorrupt && pTitleState->m_pMember->m_pTitleMenu->m_CursorIndex == 1) - pTitleState->m_pMember->m_pTitleMenu->m_CursorIndex = 0; + if (App::s_isSaveDataCorrupt && pContext->m_pTitleMenu->m_CursorIndex == 1) + pContext->m_pTitleMenu->m_CursorIndex = 0; if (!OptionsMenu::s_isVisible && isOptionsIndex) {