Skip to content

Commit 16b62a7

Browse files
authored
Fix Tropical Jungle swing vines at HFR (#152)
1 parent efafdc7 commit 16b62a7

2 files changed

Lines changed: 93 additions & 0 deletions

File tree

MarathonRecomp/patches/fps_patches.cpp

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,61 @@ void SonicCamera_RotationSpeedFix(PPCRegister& f0, PPCRegister& deltaTime, PPCRe
2323
{
2424
f0.f64 = float((f0.f64 * (deltaTime.f64 * (1.0 / (deltaTime.f64 * 60.0)))) + f13.f64);
2525
}
26+
27+
bool ObjTarzan_VolatileBranch(PPCRegister& r30)
28+
{
29+
if (Config::FPS <= 60.0f)
30+
return false;
31+
32+
return r30.f64 >= 0;
33+
}
34+
35+
void ObjTarzan_PatchStaticDeltaTime(PPCRegister& value, PPCRegister& delta)
36+
{
37+
if (Config::FPS <= 60.0f)
38+
return;
39+
40+
value.f64 = delta.f64;
41+
}
42+
43+
void ObjTarzan_PatchDeltaTimeArgument(PPCRegister& value, PPCRegister& value2, PPCRegister& stack)
44+
{
45+
if (Config::FPS <= 60.0f)
46+
return;
47+
48+
auto deltaTime = *(be<double>*)g_memory.Translate(stack.u32 + 0x90 + 0x420 - 0x88);
49+
50+
value.f64 = deltaTime;
51+
value2.f64 = deltaTime;
52+
}
53+
54+
// Sonicteam::ObjTarzan::UpdatePoint (speculatory)
55+
PPC_FUNC_IMPL(__imp__sub_8232D770);
56+
PPC_FUNC(sub_8232D770)
57+
{
58+
if (Config::FPS <= 60.0f)
59+
{
60+
__imp__sub_8232D770(ctx, base);
61+
return;
62+
}
63+
64+
struct TarzanPoint
65+
{
66+
MARATHON_INSERT_PADDING(0x4C);
67+
be<float> m_Time;
68+
MARATHON_INSERT_PADDING(0xB0);
69+
};
70+
71+
auto pTarzanPoint = (TarzanPoint*)(base + ctx.r3.u32);
72+
auto deltaTime = ctx.f1.f64;
73+
74+
if (deltaTime > 1.0)
75+
deltaTime = 1.0;
76+
77+
do
78+
{
79+
GuestToHostFunction<void>(sub_8232D288, pTarzanPoint, ctx.f1.u64, deltaTime, deltaTime, deltaTime);
80+
pTarzanPoint->m_Time = pTarzanPoint->m_Time - deltaTime;
81+
}
82+
while (pTarzanPoint->m_Time >= deltaTime);
83+
}

MarathonRecompLib/config/Marathon.toml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,3 +398,38 @@ jump_address_on_true = 0x822106C0
398398
name = "DisablePushState"
399399
address = 0x821A03F0
400400
jump_address_on_true = 0x821A03FC
401+
402+
[[midasm_hook]]
403+
name = "ObjTarzan_VolatileBranch"
404+
address = 0x8232D3E0
405+
registers = ["r30"]
406+
jump_address_on_true = 0x8232D3E4
407+
408+
[[midasm_hook]]
409+
name = "ObjTarzan_PatchStaticDeltaTime"
410+
address = 0x8232D3E4
411+
registers = ["f0", "r30"]
412+
after_instruction = true
413+
414+
[[midasm_hook]]
415+
name = "ObjTarzan_PatchStaticDeltaTime"
416+
address = 0x8232D49C
417+
registers = ["f1", "f3"]
418+
after_instruction = true
419+
420+
[[midasm_hook]]
421+
name = "ObjTarzan_PatchStaticDeltaTime"
422+
address = 0x8232D530
423+
registers = ["f1", "f3"]
424+
after_instruction = true
425+
426+
[[midasm_hook]]
427+
name = "ObjTarzan_PatchStaticDeltaTime"
428+
address = 0x8232D57C
429+
registers = ["f0", "f3"]
430+
after_instruction = true
431+
432+
[[midasm_hook]]
433+
name = "ObjTarzan_PatchDeltaTimeArgument"
434+
address = 0x8232D818
435+
registers = ["f3", "r4", "r1"]

0 commit comments

Comments
 (0)