From b56b7af321c230f7a6519ae0eb9bccad7757dcb3 Mon Sep 17 00:00:00 2001 From: Hyper <34012267+hyperbx@users.noreply.github.com> Date: Wed, 30 Jul 2025 01:41:52 +0100 Subject: [PATCH] Implemented preliminary variable frame rate support --- MarathonRecomp/api/Marathon.h | 3 +++ MarathonRecomp/api/README.md | 11 +---------- MarathonRecomp/api/Sonicteam/AppMarathon.h | 14 ++++++++++++++ MarathonRecomp/api/Sonicteam/DocMarathonImp.h | 14 ++++++++++++++ MarathonRecomp/api/Sonicteam/DocMarathonState.h | 9 +++++++++ MarathonRecomp/app.cpp | 5 +++++ MarathonRecomp/app.h | 2 ++ 7 files changed, 48 insertions(+), 10 deletions(-) create mode 100644 MarathonRecomp/api/Sonicteam/AppMarathon.h create mode 100644 MarathonRecomp/api/Sonicteam/DocMarathonImp.h create mode 100644 MarathonRecomp/api/Sonicteam/DocMarathonState.h diff --git a/MarathonRecomp/api/Marathon.h b/MarathonRecomp/api/Marathon.h index 035daab7a..b7ee1c2a8 100644 --- a/MarathonRecomp/api/Marathon.h +++ b/MarathonRecomp/api/Marathon.h @@ -15,6 +15,9 @@ #include "CSD/Manager/csdmSceneObserver.h" #include "CSD/Manager/csdmSubjectBase.h" #include "CSD/Platform/csdTexList.h" +#include "Sonicteam/AppMarathon.h" +#include "Sonicteam/DocMarathonImp.h" +#include "Sonicteam/DocMarathonState.h" #include "Sonicteam/SoX/Component.h" #include "Sonicteam/SoX/Engine/Doc.h" #include "Sonicteam/SoX/Engine/Task.h" diff --git a/MarathonRecomp/api/README.md b/MarathonRecomp/api/README.md index a2842886c..f038c02c7 100644 --- a/MarathonRecomp/api/README.md +++ b/MarathonRecomp/api/README.md @@ -5,24 +5,15 @@ ### Naming Conventions - Use `camelCase` for local variables, `SNAKE_CASE` for preprocessor macros, and `PascalCase` for everything else. Marathon-specific types that don't exist in the game should use `snake_case` for better differentiation. -- Class names should be prefixed with `C`, e.g., `CSonicContext`. -- Struct names should be prefixed with `S`, e.g., `SUpdateInfo`. - Class members should be prefixed with `m_`, e.g., `m_Time`. Do not use this prefix for struct members. -- Enum names should be prefixed with `E`, e.g., `ELightType`. -- Enum members should start with `e`, followed by the enum name and an underscore, e.g., `eLightType_Point`. -- For enum members indicating the count of elements, prefix with `n`, followed by the name, e.g., `nLightType`. - Pointers should be prefixed with `p`, e.g., `pSonicContext`. - Shared pointers should be prefixed with `sp`, e.g., `spDatabase`. - References should be prefixed with `r`, e.g., `rMessage`. -- Input function arguments should be prefixed with `in_`, e.g., `in_Name`. -- Output function arguments should be prefixed with `out_`, e.g., `out_Value`. -- Static class members should be prefixed with `ms_`, e.g., `ms_Instance`. - Static members outside a class should be prefixed with `g_`, e.g., `g_AllocationTracker`. - Marathon-specific preprocessor macros should start with `MARATHON_`, e.g., `MARATHON_INSERT_PADDING`. -- Hedgehog namespace-specific preprocessor macros should start with `HH_` along with the library's shorthand, e.g., `HH_FND_MSG_MAKE_TYPE`. - Function pointers should be prefixed with `fp`, e.g., `fpCGameObjectConstructor`. -Combine prefixes as necessary, e.g., `m_sp` for a shared pointer as a class member or `in_r` for a const reference as a function argument. +Combine prefixes as necessary, e.g., `m_sp` for a shared pointer as a class member. ### Coding Style diff --git a/MarathonRecomp/api/Sonicteam/AppMarathon.h b/MarathonRecomp/api/Sonicteam/AppMarathon.h new file mode 100644 index 000000000..38ecab00a --- /dev/null +++ b/MarathonRecomp/api/Sonicteam/AppMarathon.h @@ -0,0 +1,14 @@ +#pragma once + +#include +#include + +namespace Sonicteam +{ + class AppMarathon + { + public: + MARATHON_INSERT_PADDING(0x180); + xpointer m_pDoc; + }; +} diff --git a/MarathonRecomp/api/Sonicteam/DocMarathonImp.h b/MarathonRecomp/api/Sonicteam/DocMarathonImp.h new file mode 100644 index 000000000..e471f20a5 --- /dev/null +++ b/MarathonRecomp/api/Sonicteam/DocMarathonImp.h @@ -0,0 +1,14 @@ +#pragma once + +#include +#include + +namespace Sonicteam +{ + class DocMarathonImp : public Sonicteam::SoX::Engine::Doc + { + public: + MARATHON_INSERT_PADDING(0x74); + bool m_VFrame; + }; +} diff --git a/MarathonRecomp/api/Sonicteam/DocMarathonState.h b/MarathonRecomp/api/Sonicteam/DocMarathonState.h new file mode 100644 index 000000000..cd88da4b8 --- /dev/null +++ b/MarathonRecomp/api/Sonicteam/DocMarathonState.h @@ -0,0 +1,9 @@ +#pragma once + +#include +#include + +namespace Sonicteam +{ + class DocMarathonState : public DocMarathonImp {}; +} diff --git a/MarathonRecomp/app.cpp b/MarathonRecomp/app.cpp index 7dac67e1a..fa2bd48cc 100644 --- a/MarathonRecomp/app.cpp +++ b/MarathonRecomp/app.cpp @@ -51,6 +51,8 @@ PPC_FUNC(sub_8262A568) LOGFN_UTILITY("Changed resolution: {}x{}", cfg->Width.get(), cfg->Height.get()); __imp__sub_8262A568(ctx, base); + + App::s_pApp = (Sonicteam::AppMarathon*)g_memory.Translate(ctx.r3.u32); } // Sonicteam::DocMarathonState::Update @@ -83,6 +85,9 @@ PPC_FUNC(sub_825EA610) SDL_FlushEvents(SDL_FIRSTEVENT, SDL_LASTEVENT); GameWindow::Update(); } + + // Allow variable FPS when config is not 60 FPS. + App::s_pApp->m_pDoc->m_VFrame = Config::FPS != 60; } PPC_FUNC_IMPL(__imp__sub_82582648); diff --git a/MarathonRecomp/app.h b/MarathonRecomp/app.h index 8facd0ea0..da7fe65a9 100644 --- a/MarathonRecomp/app.h +++ b/MarathonRecomp/app.h @@ -12,6 +12,8 @@ class App static inline bool s_isSaving; static inline bool s_isSaveDataCorrupt; + static inline Sonicteam::AppMarathon* s_pApp; + static inline EPlayerCharacter s_playerCharacter; static inline ELanguage s_language;