Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions MarathonRecomp/patches/fps_patches.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,61 @@ void SonicCamera_RotationSpeedFix(PPCRegister& f0, PPCRegister& deltaTime, PPCRe
{
f0.f64 = float((f0.f64 * (deltaTime.f64 * (1.0 / (deltaTime.f64 * 60.0)))) + f13.f64);
}

bool ObjTarzan_VolatileBranch(PPCRegister& r30)
{
if (Config::FPS <= 60.0f)
return false;

return r30.f64 >= 0;
}

void ObjTarzan_PatchStaticDeltaTime(PPCRegister& value, PPCRegister& delta)
{
if (Config::FPS <= 60.0f)
return;

value.f64 = delta.f64;
}

void ObjTarzan_PatchDeltaTimeArgument(PPCRegister& value, PPCRegister& value2, PPCRegister& stack)
{
if (Config::FPS <= 60.0f)
return;

auto deltaTime = *(be<double>*)g_memory.Translate(stack.u32 + 0x90 + 0x420 - 0x88);

value.f64 = deltaTime;
value2.f64 = deltaTime;
}

// Sonicteam::ObjTarzan::UpdatePoint (speculatory)
PPC_FUNC_IMPL(__imp__sub_8232D770);
PPC_FUNC(sub_8232D770)
{
if (Config::FPS <= 60.0f)
{
__imp__sub_8232D770(ctx, base);
return;
}

struct TarzanPoint
{
MARATHON_INSERT_PADDING(0x4C);
be<float> m_Time;
MARATHON_INSERT_PADDING(0xB0);
};

auto pTarzanPoint = (TarzanPoint*)(base + ctx.r3.u32);
auto deltaTime = ctx.f1.f64;

if (deltaTime > 1.0)
deltaTime = 1.0;

do
{
GuestToHostFunction<void>(sub_8232D288, pTarzanPoint, ctx.f1.u64, deltaTime, deltaTime, deltaTime);
pTarzanPoint->m_Time = pTarzanPoint->m_Time - deltaTime;
}
while (pTarzanPoint->m_Time >= deltaTime);
}
35 changes: 35 additions & 0 deletions MarathonRecompLib/config/Marathon.toml
Original file line number Diff line number Diff line change
Expand Up @@ -398,3 +398,38 @@ jump_address_on_true = 0x822106C0
name = "DisablePushState"
address = 0x821A03F0
jump_address_on_true = 0x821A03FC

[[midasm_hook]]
name = "ObjTarzan_VolatileBranch"
address = 0x8232D3E0
registers = ["r30"]
jump_address_on_true = 0x8232D3E4

[[midasm_hook]]
name = "ObjTarzan_PatchStaticDeltaTime"
address = 0x8232D3E4
registers = ["f0", "r30"]
after_instruction = true

[[midasm_hook]]
name = "ObjTarzan_PatchStaticDeltaTime"
address = 0x8232D49C
registers = ["f1", "f3"]
after_instruction = true

[[midasm_hook]]
name = "ObjTarzan_PatchStaticDeltaTime"
address = 0x8232D530
registers = ["f1", "f3"]
after_instruction = true

[[midasm_hook]]
name = "ObjTarzan_PatchStaticDeltaTime"
address = 0x8232D57C
registers = ["f0", "f3"]
after_instruction = true

[[midasm_hook]]
name = "ObjTarzan_PatchDeltaTimeArgument"
address = 0x8232D818
registers = ["f3", "r4", "r1"]
Loading