Skip to content

Commit 9be8eba

Browse files
authored
Implemented preliminary variable frame rate support (#24)
1 parent 833cae6 commit 9be8eba

7 files changed

Lines changed: 48 additions & 10 deletions

File tree

MarathonRecomp/api/Marathon.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
#include "CSD/Manager/csdmSceneObserver.h"
1616
#include "CSD/Manager/csdmSubjectBase.h"
1717
#include "CSD/Platform/csdTexList.h"
18+
#include "Sonicteam/AppMarathon.h"
19+
#include "Sonicteam/DocMarathonImp.h"
20+
#include "Sonicteam/DocMarathonState.h"
1821
#include "Sonicteam/SoX/Component.h"
1922
#include "Sonicteam/SoX/Engine/Doc.h"
2023
#include "Sonicteam/SoX/Engine/Task.h"

MarathonRecomp/api/README.md

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,15 @@
55
### Naming Conventions
66

77
- 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.
8-
- Class names should be prefixed with `C`, e.g., `CSonicContext`.
9-
- Struct names should be prefixed with `S`, e.g., `SUpdateInfo`.
108
- Class members should be prefixed with `m_`, e.g., `m_Time`. Do not use this prefix for struct members.
11-
- Enum names should be prefixed with `E`, e.g., `ELightType`.
12-
- Enum members should start with `e`, followed by the enum name and an underscore, e.g., `eLightType_Point`.
13-
- For enum members indicating the count of elements, prefix with `n`, followed by the name, e.g., `nLightType`.
149
- Pointers should be prefixed with `p`, e.g., `pSonicContext`.
1510
- Shared pointers should be prefixed with `sp`, e.g., `spDatabase`.
1611
- References should be prefixed with `r`, e.g., `rMessage`.
17-
- Input function arguments should be prefixed with `in_`, e.g., `in_Name`.
18-
- Output function arguments should be prefixed with `out_`, e.g., `out_Value`.
19-
- Static class members should be prefixed with `ms_`, e.g., `ms_Instance`.
2012
- Static members outside a class should be prefixed with `g_`, e.g., `g_AllocationTracker`.
2113
- Marathon-specific preprocessor macros should start with `MARATHON_`, e.g., `MARATHON_INSERT_PADDING`.
22-
- Hedgehog namespace-specific preprocessor macros should start with `HH_` along with the library's shorthand, e.g., `HH_FND_MSG_MAKE_TYPE`.
2314
- Function pointers should be prefixed with `fp`, e.g., `fpCGameObjectConstructor`.
2415

25-
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.
16+
Combine prefixes as necessary, e.g., `m_sp` for a shared pointer as a class member.
2617

2718
### Coding Style
2819

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#pragma once
2+
3+
#include <Marathon.inl>
4+
#include <Sonicteam/DocMarathonState.h>
5+
6+
namespace Sonicteam
7+
{
8+
class AppMarathon
9+
{
10+
public:
11+
MARATHON_INSERT_PADDING(0x180);
12+
xpointer<DocMarathonState> m_pDoc;
13+
};
14+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#pragma once
2+
3+
#include <Marathon.inl>
4+
#include <Sonicteam/SoX/Engine/Doc.h>
5+
6+
namespace Sonicteam
7+
{
8+
class DocMarathonImp : public Sonicteam::SoX::Engine::Doc
9+
{
10+
public:
11+
MARATHON_INSERT_PADDING(0x74);
12+
bool m_VFrame;
13+
};
14+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#pragma once
2+
3+
#include <Marathon.inl>
4+
#include <Sonicteam/DocMarathonImp.h>
5+
6+
namespace Sonicteam
7+
{
8+
class DocMarathonState : public DocMarathonImp {};
9+
}

MarathonRecomp/app.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ PPC_FUNC(sub_8262A568)
5151
LOGFN_UTILITY("Changed resolution: {}x{}", cfg->Width.get(), cfg->Height.get());
5252

5353
__imp__sub_8262A568(ctx, base);
54+
55+
App::s_pApp = (Sonicteam::AppMarathon*)g_memory.Translate(ctx.r3.u32);
5456
}
5557

5658
// Sonicteam::DocMarathonState::Update
@@ -83,6 +85,9 @@ PPC_FUNC(sub_825EA610)
8385
SDL_FlushEvents(SDL_FIRSTEVENT, SDL_LASTEVENT);
8486
GameWindow::Update();
8587
}
88+
89+
// Allow variable FPS when config is not 60 FPS.
90+
App::s_pApp->m_pDoc->m_VFrame = Config::FPS != 60;
8691
}
8792

8893
PPC_FUNC_IMPL(__imp__sub_82582648);

MarathonRecomp/app.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ class App
1212
static inline bool s_isSaving;
1313
static inline bool s_isSaveDataCorrupt;
1414

15+
static inline Sonicteam::AppMarathon* s_pApp;
16+
1517
static inline EPlayerCharacter s_playerCharacter;
1618
static inline ELanguage s_language;
1719

0 commit comments

Comments
 (0)