Merge branch 'main' into dpad-movement-safe-hooks

This commit is contained in:
Hyper 2025-01-19 15:00:06 +00:00 committed by GitHub
commit 84b0e8567f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 143 additions and 44 deletions

View file

@ -154,8 +154,9 @@ set(SWA_PATCHES_CXX_SOURCES
"patches/ui/frontend_listener.cpp" "patches/ui/frontend_listener.cpp"
"patches/aspect_ratio_patches.cpp" "patches/aspect_ratio_patches.cpp"
"patches/audio_patches.cpp" "patches/audio_patches.cpp"
"patches/camera_patches.cpp" "patches/camera_patches.cpp"
"patches/fps_patches.cpp" "patches/CGameModeStageTitle_patches.cpp"
"patches/fps_patches.cpp"
"patches/input_patches.cpp" "patches/input_patches.cpp"
"patches/inspire_patches.cpp" "patches/inspire_patches.cpp"
"patches/misc_patches.cpp" "patches/misc_patches.cpp"
@ -197,22 +198,22 @@ set(SWA_INSTALL_CXX_SOURCES
set(SWA_USER_CXX_SOURCES set(SWA_USER_CXX_SOURCES
"user/achievement_data.cpp" "user/achievement_data.cpp"
"user/config.cpp" "user/config.cpp"
) )
set(SWA_MOD_CXX_SOURCES set(SWA_MOD_CXX_SOURCES
"mod/mod_loader.cpp" "mod/mod_loader.cpp"
) )
set(SWA_THIRDPARTY_SOURCES set(SWA_THIRDPARTY_SOURCES
"${SWA_THIRDPARTY_ROOT}/imgui/backends/imgui_impl_sdl2.cpp" "${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_demo.cpp"
"${SWA_THIRDPARTY_ROOT}/imgui/imgui_draw.cpp" "${SWA_THIRDPARTY_ROOT}/imgui/imgui_draw.cpp"
"${SWA_THIRDPARTY_ROOT}/imgui/imgui_tables.cpp" "${SWA_THIRDPARTY_ROOT}/imgui/imgui_tables.cpp"
"${SWA_THIRDPARTY_ROOT}/imgui/imgui_widgets.cpp" "${SWA_THIRDPARTY_ROOT}/imgui/imgui_widgets.cpp"
"${SWA_THIRDPARTY_ROOT}/implot/implot.cpp" "${SWA_THIRDPARTY_ROOT}/implot/implot.cpp"
"${SWA_THIRDPARTY_ROOT}/implot/implot_demo.cpp" "${SWA_THIRDPARTY_ROOT}/implot/implot_demo.cpp"
"${SWA_THIRDPARTY_ROOT}/implot/implot_items.cpp" "${SWA_THIRDPARTY_ROOT}/implot/implot_items.cpp"
"${SWA_THIRDPARTY_ROOT}/libmspack/libmspack/mspack/lzxd.c" "${SWA_THIRDPARTY_ROOT}/libmspack/libmspack/mspack/lzxd.c"
"${SWA_THIRDPARTY_ROOT}/tiny-AES-c/aes.c" "${SWA_THIRDPARTY_ROOT}/tiny-AES-c/aes.c"
"${SWA_TOOLS_ROOT}/ShaderRecomp/thirdparty/smol-v/source/smolv.cpp" "${SWA_TOOLS_ROOT}/ShaderRecomp/thirdparty/smol-v/source/smolv.cpp"
@ -221,7 +222,7 @@ set(SWA_THIRDPARTY_SOURCES
set(SWA_THIRDPARTY_INCLUDES set(SWA_THIRDPARTY_INCLUDES
"${SWA_THIRDPARTY_ROOT}/concurrentqueue" "${SWA_THIRDPARTY_ROOT}/concurrentqueue"
"${SWA_THIRDPARTY_ROOT}/ddspp" "${SWA_THIRDPARTY_ROOT}/ddspp"
"${SWA_THIRDPARTY_ROOT}/imgui" "${SWA_THIRDPARTY_ROOT}/imgui"
"${SWA_THIRDPARTY_ROOT}/implot" "${SWA_THIRDPARTY_ROOT}/implot"
"${SWA_THIRDPARTY_ROOT}/libmspack/libmspack/mspack" "${SWA_THIRDPARTY_ROOT}/libmspack/libmspack/mspack"
"${SWA_THIRDPARTY_ROOT}/magic_enum/include" "${SWA_THIRDPARTY_ROOT}/magic_enum/include"
@ -248,7 +249,7 @@ set(SWA_CXX_SOURCES
"exports.cpp" "exports.cpp"
"main.cpp" "main.cpp"
"misc_impl.cpp" "misc_impl.cpp"
"stdafx.cpp" "stdafx.cpp"
"version.cpp" "version.cpp"
${SWA_KERNEL_CXX_SOURCES} ${SWA_KERNEL_CXX_SOURCES}
@ -261,7 +262,7 @@ set(SWA_CXX_SOURCES
${SWA_PATCHES_CXX_SOURCES} ${SWA_PATCHES_CXX_SOURCES}
${SWA_UI_CXX_SOURCES} ${SWA_UI_CXX_SOURCES}
${SWA_INSTALL_CXX_SOURCES} ${SWA_INSTALL_CXX_SOURCES}
${SWA_USER_CXX_SOURCES} ${SWA_USER_CXX_SOURCES}
${SWA_MOD_CXX_SOURCES} ${SWA_MOD_CXX_SOURCES}
${SWA_THIRDPARTY_SOURCES} ${SWA_THIRDPARTY_SOURCES}
) )
@ -275,7 +276,7 @@ else()
add_executable(UnleashedRecomp ${SWA_CXX_SOURCES}) add_executable(UnleashedRecomp ${SWA_CXX_SOURCES})
endif() endif()
set_target_properties(UnleashedRecomp PROPERTIES OUTPUT_NAME ${TARGET_NAME}) set_target_properties(UnleashedRecomp PROPERTIES OUTPUT_NAME ${TARGET_NAME})
if (SWA_FLATPAK) if (SWA_FLATPAK)
target_compile_definitions(UnleashedRecomp PRIVATE "GAME_INSTALL_DIRECTORY=\"/var/data\"") target_compile_definitions(UnleashedRecomp PRIVATE "GAME_INSTALL_DIRECTORY=\"/var/data\"")
@ -381,8 +382,8 @@ function(compile_pixel_shader FILE_PATH)
endfunction() endfunction()
compile_vertex_shader(copy_vs) compile_vertex_shader(copy_vs)
compile_pixel_shader(csd_filter_ps) compile_pixel_shader(csd_filter_ps)
compile_vertex_shader(csd_no_tex_vs) compile_vertex_shader(csd_no_tex_vs)
compile_vertex_shader(csd_vs) compile_vertex_shader(csd_vs)
compile_pixel_shader(enhanced_motion_blur_ps) compile_pixel_shader(enhanced_motion_blur_ps)
compile_pixel_shader(gaussian_blur_3x3) compile_pixel_shader(gaussian_blur_3x3)
@ -426,21 +427,21 @@ generate_aggregate_header(
"${CMAKE_CURRENT_SOURCE_DIR}/api" "${CMAKE_CURRENT_SOURCE_DIR}/api"
"${CMAKE_CURRENT_SOURCE_DIR}/api/SWA.h" "${CMAKE_CURRENT_SOURCE_DIR}/api/SWA.h"
) )
# Only show build type if not Release. # Only show build type if not Release.
set(IS_BUILD_TYPE_IN_VER_STRING 0) set(IS_BUILD_TYPE_IN_VER_STRING 0)
if (NOT ${CMAKE_BUILD_TYPE} MATCHES "Release") if (NOT ${CMAKE_BUILD_TYPE} MATCHES "Release")
set(IS_BUILD_TYPE_IN_VER_STRING 1) set(IS_BUILD_TYPE_IN_VER_STRING 1)
endif() endif()
include("version.cmake") include("version.cmake")
GenerateVersionSources( GenerateVersionSources(
OUTPUT_DIR "${PROJECT_SOURCE_DIR}" OUTPUT_DIR "${PROJECT_SOURCE_DIR}"
VERSION_TXT "${PROJECT_SOURCE_DIR}/res/version.txt" VERSION_TXT "${PROJECT_SOURCE_DIR}/res/version.txt"
H_TEMPLATE "${PROJECT_SOURCE_DIR}/res/version.h.template" H_TEMPLATE "${PROJECT_SOURCE_DIR}/res/version.h.template"
CXX_TEMPLATE "${PROJECT_SOURCE_DIR}/res/version.cpp.template" CXX_TEMPLATE "${PROJECT_SOURCE_DIR}/res/version.cpp.template"
BUILD_TYPE ${CMAKE_BUILD_TYPE} BUILD_TYPE ${CMAKE_BUILD_TYPE}
IS_BUILD_TYPE_IN_VER_STRING ${IS_BUILD_TYPE_IN_VER_STRING} IS_BUILD_TYPE_IN_VER_STRING ${IS_BUILD_TYPE_IN_VER_STRING}
IS_GIT_REPO 1 IS_GIT_REPO 1
) )

View file

@ -0,0 +1,32 @@
#pragma once
#include <SWA.inl>
#include <Hedgehog/Base/hhObject.h>
#include <Hedgehog/Universe/Engine/hhMessageProcess.h>
#include <Hedgehog/Universe/Engine/hhStateMachineMessageReceiver.h>
namespace Hedgehog::Universe
{
class CStateMachineBase : public IStateMachineMessageReceiver, public Base::CObject
{
public:
class CStateBase : public IMessageProcess
{
public:
SWA_INSERT_PADDING(0x08);
xpointer<void> m_pContext;
xpointer<CStateMachineBase> m_pStateMachine;
be<float> m_Time;
SWA_INSERT_PADDING(0x4C);
void* GetContextBase() const;
template<typename T>
T* GetContextBase() const;
};
SWA_INSERT_PADDING(0x60);
};
}
#include <Hedgehog/Universe/Engine/hhStateMachineBase.inl>

View file

@ -0,0 +1,13 @@
namespace Hedgehog::Universe
{
inline void* CStateMachineBase::CStateBase::GetContextBase() const
{
return m_pContext;
}
template<typename T>
inline T* CStateMachineBase::CStateBase::GetContextBase() const
{
return (T*)m_pContext.get();
}
}

View file

@ -0,0 +1,12 @@
#pragma once
#include <SWA.inl>
namespace Hedgehog::Universe
{
class IStateMachineMessageReceiver
{
public:
IStateMachineMessageReceiver(const swa_null_ctor&) {}
};
}

View file

@ -47,6 +47,8 @@
#include "Hedgehog/Sparkle/hhParticleMaterial.h" #include "Hedgehog/Sparkle/hhParticleMaterial.h"
#include "Hedgehog/Universe/Engine/hhMessageActor.h" #include "Hedgehog/Universe/Engine/hhMessageActor.h"
#include "Hedgehog/Universe/Engine/hhMessageProcess.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/hhUpdateInfo.h"
#include "Hedgehog/Universe/Engine/hhUpdateUnit.h" #include "Hedgehog/Universe/Engine/hhUpdateUnit.h"
#include "Hedgehog/Universe/Thread/hhParallelJob.h" #include "Hedgehog/Universe/Thread/hhParallelJob.h"
@ -91,8 +93,10 @@
#include "SWA/System/GameMode/GameMode.h" #include "SWA/System/GameMode/GameMode.h"
#include "SWA/System/GameMode/GameModeStage.h" #include "SWA/System/GameMode/GameModeStage.h"
#include "SWA/System/GameMode/GameModeStageMovie.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/TitleMenu.h"
#include "SWA/System/GameMode/Title/TitleStateBase.h" #include "SWA/System/GameMode/Title/TitleStateBase.h"
#include "SWA/System/GameMode/Title/TitleStateIntro.h"
#include "SWA/System/GameObject.h" #include "SWA/System/GameObject.h"
#include "SWA/System/GameParameter.h" #include "SWA/System/GameParameter.h"
#include "SWA/System/GammaController.h" #include "SWA/System/GammaController.h"

View file

@ -4,10 +4,9 @@
namespace SWA namespace SWA
{ {
class CGameMode // : Hedgehog::Universe::TStateMachine<SWA::CGame>::TState class CGameMode : public Hedgehog::Universe::CStateMachineBase::CStateBase
{ {
public: public:
SWA_INSERT_PADDING(0x60); // base
SWA_INSERT_PADDING(0x08); SWA_INSERT_PADDING(0x08);
}; };
} }

View file

@ -0,0 +1,14 @@
#pragma once
#include <SWA.inl>
namespace SWA
{
class CGameModeStageTitle : public CGameModeStage
{
public:
SWA_INSERT_PADDING(0x0E);
bool m_IsPlayingAdvertiseMovie;
be<float> m_AdvertiseMovieWaitTime;
};
}

View file

@ -4,19 +4,14 @@
namespace SWA namespace SWA
{ {
class CTitleStateBase // : Hedgehog::Universe::TStateMachine<SWA::CTitleManager>::TState class CTitleStateBase : public Hedgehog::Universe::CStateMachineBase::CStateBase
{ {
public: public:
class CMember class CTitleStateContext
{ {
public: public:
SWA_INSERT_PADDING(0x1E8); SWA_INSERT_PADDING(0x1E8);
xpointer<CTitleMenu> m_pTitleMenu; xpointer<CTitleMenu> m_pTitleMenu;
}; };
SWA_INSERT_PADDING(0x08);
xpointer<CMember> m_pMember;
SWA_INSERT_PADDING(0x5C);
be<uint32_t> m_State;
}; };
} }

View file

@ -0,0 +1,8 @@
#pragma once
#include <SWA.inl>
namespace SWA
{
class CTitleStateIntro : public CTitleStateBase {};
}

View file

@ -0,0 +1,14 @@
#include <api/SWA.h>
#include <patches/ui/CTitleStateIntro_patches.h>
// 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;
}

View file

@ -1,3 +1,4 @@
#include "CTitleStateIntro_patches.h"
#include <api/SWA.h> #include <api/SWA.h>
#include <locale/locale.h> #include <locale/locale.h>
#include <ui/fader.h> #include <ui/fader.h>

View file

@ -0,0 +1,3 @@
#pragma once
extern bool g_quitMessageOpen;

View file

@ -50,15 +50,18 @@ PPC_FUNC_IMPL(__imp__sub_825882B8);
PPC_FUNC(sub_825882B8) PPC_FUNC(sub_825882B8)
{ {
auto pTitleState = (SWA::CTitleStateBase*)g_memory.Translate(ctx.r3.u32); auto pTitleState = (SWA::CTitleStateBase*)g_memory.Translate(ctx.r3.u32);
auto pInputState = SWA::CInputState::GetInstance(); auto pInputState = SWA::CInputState::GetInstance();
auto& pPadState = pInputState->GetPadState(); auto& pPadState = pInputState->GetPadState();
auto isAccepted = pPadState.IsTapped(SWA::eKeyState_A) || pPadState.IsTapped(SWA::eKeyState_Start); 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<SWA::CTitleStateBase::CTitleStateContext>();
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. // Always default to New Game with corrupted save data.
if (App::s_isSaveDataCorrupt && pTitleState->m_pMember->m_pTitleMenu->m_CursorIndex == 1) if (App::s_isSaveDataCorrupt && pContext->m_pTitleMenu->m_CursorIndex == 1)
pTitleState->m_pMember->m_pTitleMenu->m_CursorIndex = 0; pContext->m_pTitleMenu->m_CursorIndex = 0;
if (!OptionsMenu::s_isVisible && isOptionsIndex) if (!OptionsMenu::s_isVisible && isOptionsIndex)
{ {