Skip to content

Commit

Permalink
FramerateUnlock: fix speed of flashing car color changes
Browse files Browse the repository at this point in the history
  • Loading branch information
emoose committed Sep 18, 2024
1 parent f1ed60b commit e3fe8f5
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/hooks_framerate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,16 @@ class ReplaceGameUpdateLoop : public Hook
}
}

// EventDisplay adds to sin_param every frame, if GetPauseFlag is false
// This causes speed of flashing cars to change depending on framerate
// We'll update it similar to SetTweeningTable so it only increments if a game tick is being ran
inline static SafetyHookMid EventDisplay_midhook = {};
static void EventDisplay_dest(SafetyHookContext& ctx)
{
if (*Game::sprani_num_ticks == 0)
ctx.eax = 1; // make func think that game is paused
}

public:
std::string_view description() override
{
Expand Down Expand Up @@ -263,7 +273,6 @@ class ReplaceGameUpdateLoop : public Hook

constexpr int HookAddr = 0x17C7B;
constexpr int GameLoopFrameLimiterAddr = 0x17DD3;
constexpr int SetTweeningTable_Addr = 0xED60;
constexpr int GameLoopFileLoad_CtrlCaller = 0x17D8D;

// disable broken framelimiter
Expand All @@ -281,8 +290,12 @@ class ReplaceGameUpdateLoop : public Hook
Memory::VP::Nop(Module::exe_ptr(GameLoopFileLoad_CtrlCaller), 5);

if (Settings::FramerateUnlockExperimental)
SetTweeningTable = safetyhook::create_inline(Module::exe_ptr<uint8_t>(SetTweeningTable_Addr), SetTweeningTable_dest);

{
constexpr int SetTweeningTable_Addr = 0xED60;
constexpr int EventDisplay_HookAddr = 0x3FC48;
SetTweeningTable = safetyhook::create_inline(Module::exe_ptr(SetTweeningTable_Addr), SetTweeningTable_dest);
EventDisplay_midhook = safetyhook::create_mid(Module::exe_ptr(EventDisplay_HookAddr), EventDisplay_dest);
}
return !!dest_hook;
}

Expand Down

0 comments on commit e3fe8f5

Please sign in to comment.