summaryrefslogtreecommitdiff
path: root/src/port
diff options
context:
space:
mode:
authorNicholas Estelami <NEstelami@users.noreply.github.com>2025-03-28 03:25:11 -0400
committerGitHub <noreply@github.com>2025-03-28 04:25:11 -0300
commit30ec4720c06dd3418641226a6d320067f2706700 (patch)
tree39a6a83b02325b4a027d260854a84f50b5abcfcc /src/port
parentea4254984225884476c66da8563166505bfd4aee (diff)
Floor Scrolling Interpolation (#176)
* Floor Scrolling Interpolation * Scrolling Improvements * Fix scroll stutter * bump LUS & Torch * missing prototype --------- Co-authored-by: Sonic Dreamcaster <alejandro.asenjo88@gmail.com>
Diffstat (limited to 'src/port')
-rw-r--r--src/port/Engine.cpp12
-rw-r--r--src/port/Engine.h5
-rw-r--r--src/port/GBIMiddleware.cpp9
3 files changed, 25 insertions, 1 deletions
diff --git a/src/port/Engine.cpp b/src/port/Engine.cpp
index 4da6fd77..e0307752 100644
--- a/src/port/Engine.cpp
+++ b/src/port/Engine.cpp
@@ -452,8 +452,11 @@ void GameEngine::RunCommands(Gfx* Commands, const std::vector<std::unordered_map
// Process window events for resize, mouse, keyboard events
wnd->HandleEvents();
+ gInterpolationIndex = 0;
+
for (const auto& m : mtx_replacements) {
wnd->DrawAndRunGraphicsCommands(Commands, m);
+ gInterpolationIndex++;
}
bool curAltAssets = CVarGetInteger("gEnhancements.Mods.AlternateAssets", 0);
@@ -538,6 +541,15 @@ uint32_t GameEngine::GetInterpolationFPS() {
CVarGetInteger("gInterpolationFPS", 60));
}
+uint32_t GameEngine::GetInterpolationFrameCount()
+{
+ return ceil((float)GetInterpolationFPS() / 30.0f);
+}
+
+extern "C" uint32_t GameEngine_GetInterpolationFrameCount() {
+ return GameEngine::GetInterpolationFrameCount();
+}
+
void GameEngine::ShowMessage(const char* title, const char* message, SDL_MessageBoxFlags type) {
#if defined(__SWITCH__)
SPDLOG_ERROR(message);
diff --git a/src/port/Engine.h b/src/port/Engine.h
index 26f9109f..43dbf066 100644
--- a/src/port/Engine.h
+++ b/src/port/Engine.h
@@ -39,7 +39,8 @@ class GameEngine {
static void AudioExit();
static void RunCommands(Gfx* Commands, const std::vector<std::unordered_map<Mtx*, MtxF>>& mtx_replacements);
static void Destroy();
- static uint32_t GetInterpolationFPS();
+ static uint32_t GetInterpolationFPS();
+ static uint32_t GetInterpolationFrameCount();
static void ProcessGfxCommands(Gfx* commands);
static int ShowYesNoBox(const char* title, const char* box);
@@ -80,5 +81,7 @@ uint32_t OTRGetGameRenderWidth();
uint32_t OTRGetGameRenderHeight();
void* GameEngine_Malloc(size_t size);
void GameEngine_GetTextureInfo(const char* path, int32_t* width, int32_t* height, float* scale, bool* custom);
+void gDPSetTileSizeInterp(Gfx* pkt, int t, float uls, float ult, float lrs, float lrt);
+uint32_t GameEngine_GetInterpolationFrameCount();
#define memalloc(size) GameEngine_Malloc(size)
#endif \ No newline at end of file
diff --git a/src/port/GBIMiddleware.cpp b/src/port/GBIMiddleware.cpp
index 5e35e312..e0355a6d 100644
--- a/src/port/GBIMiddleware.cpp
+++ b/src/port/GBIMiddleware.cpp
@@ -20,6 +20,15 @@ extern "C" void gSPDisplayList(Gfx* pkt, Gfx* dl) {
__gSPDisplayList(pkt, dl);
}
+extern "C" void gDPSetTileSizeInterp(Gfx* pkt, int t, float uls, float ult, float lrs, float lrt)
+{
+ __gDPSetTileSizeInterp(pkt++, t, 0, 0, 0, 0);
+ memcpy(&pkt[0].words.w0, &uls, sizeof(float));
+ memcpy(&pkt[0].words.w1, &ult, sizeof(float));
+ memcpy(&pkt[1].words.w0, &lrs, sizeof(float));
+ memcpy(&pkt[1].words.w1, &lrt, sizeof(float));
+}
+
extern "C" void gSPVertex(Gfx* pkt, uintptr_t v, int n, int v0) {
if (GameEngine_OTRSigCheck((char*)v) == 1) {