Skip to content

Commit b5601de

Browse files
committed
Clean-up
1 parent 260e230 commit b5601de

2 files changed

Lines changed: 43 additions & 68 deletions

File tree

MarathonRecomp/patches/fps_patches.cpp

Lines changed: 31 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -25,85 +25,60 @@ void SonicCamera_RotationSpeedFix(PPCRegister& f0, PPCRegister& deltaTime, PPCRe
2525
f0.f64 = float((f0.f64 * (deltaTime.f64 * (1.0 / (deltaTime.f64 * 60.0)))) + f13.f64);
2626
}
2727

28-
29-
bool FixTPJRopeHFR2BNE(PPCRegister& r30)
30-
{
31-
if (Config::FPS > 60.0)
32-
return r30.f64 >= 0;
33-
else
34-
return false; // original
35-
}
36-
37-
void FixTPJRopeHFR3LFS(PPCRegister& r_value, PPCRegister& r_delta)
38-
{
39-
if (Config::FPS <= 60.0)
40-
return;
41-
42-
r_value.f64 = r_delta.f64;
43-
}
44-
//Not finished
45-
void FixTPJRopeHFR4LFS(PPCRegister& r_value, PPCRegister& r_delta)
28+
bool ObjTarzan_VolatileBranch(PPCRegister& r30)
4629
{
47-
if (Config::FPS <= 60.0)
48-
return;
30+
if (Config::FPS <= 60.0f)
31+
return false;
4932

50-
r_value.f64 = r_delta.f64;
33+
return r30.f64 >= 0;
5134
}
52-
void FixTPJRopeHFR5LFS(PPCRegister& r_value, PPCRegister& r_delta)
53-
{
54-
if (Config::FPS <= 60.0)
55-
return;
5635

57-
r_value.f64 = r_delta.f64;
58-
}
59-
void FixTPJRopeHFR6LFS(PPCRegister& r_value, PPCRegister& r_delta)
36+
void ObjTarzan_PatchStaticDeltaTime(PPCRegister& value, PPCRegister& delta)
6037
{
61-
if (Config::FPS <= 60.0)
38+
if (Config::FPS <= 60.0f)
6239
return;
6340

64-
r_value.f64 = r_delta.f64;
41+
value.f64 = delta.f64;
6542
}
6643

67-
//force to save
68-
void FixTPJRopeHFR7EXTRA(PPCRegister& r_value, PPCRegister& r_value2, PPCRegister& r_stack)
44+
void ObjTarzan_PatchDeltaTimeArgument(PPCRegister& value, PPCRegister& value2, PPCRegister& stack)
6945
{
70-
if (Config::FPS <= 60.0)
46+
if (Config::FPS <= 60.0f)
7147
return;
7248

73-
auto deltaTime = *(be<double>*)g_memory.Translate(r_stack.u32 + 0x90 + 0x420 - 0x88);
74-
r_value.f64 = deltaTime;
75-
r_value2.f64 = deltaTime;
76-
}
77-
78-
//no Tarzan Class implementation, because Fixture in gauge patch o-o
79-
struct TPJ_POINT
80-
{
81-
MARATHON_INSERT_PADDING(0x4C);
82-
be<float> m_Time;
83-
MARATHON_INSERT_PADDING(0xB0);
49+
auto deltaTime = *(be<double>*)g_memory.Translate(stack.u32 + 0x90 + 0x420 - 0x88);
8450

85-
};
51+
value.f64 = deltaTime;
52+
value2.f64 = deltaTime;
53+
}
8654

87-
// SonicTeam::TPJ
55+
// Sonicteam::ObjTarzan::Update
8856
PPC_FUNC_IMPL(__imp__sub_8232D770);
8957
PPC_FUNC(sub_8232D770)
9058
{
91-
if (Config::FPS <= 60.0)
59+
if (Config::FPS <= 60.0f)
9260
{
9361
__imp__sub_8232D770(ctx, base);
9462
return;
9563
}
9664

97-
auto pTPJ = (TPJ_POINT*)(base + ctx.r3.u32);
98-
auto delta = ctx.f1.f64;
99-
PPCRegister _r4 = ctx.f1;
65+
struct TarzanPoint
66+
{
67+
MARATHON_INSERT_PADDING(0x4C);
68+
be<float> m_Time;
69+
MARATHON_INSERT_PADDING(0xB0);
70+
};
71+
72+
auto pTarzanPoint = (TarzanPoint*)(base + ctx.r3.u32);
73+
auto deltaTime = ctx.f1.f64;
74+
75+
if (deltaTime > 1.0)
76+
deltaTime = 1.0;
10077

101-
if (delta > 1.0)
102-
delta = 1.0;
10378
do
10479
{
105-
//f1,f2,f3
106-
GuestToHostFunction<void>(sub_8232D288, pTPJ, _r4.u64,delta,delta,delta);
107-
pTPJ->m_Time = pTPJ->m_Time - delta;
108-
} while (pTPJ->m_Time >= delta);
80+
GuestToHostFunction<void>(sub_8232D288, pTarzanPoint, ctx.f1.u64, deltaTime, deltaTime, deltaTime);
81+
pTarzanPoint->m_Time = pTarzanPoint->m_Time - deltaTime;
82+
}
83+
while (pTarzanPoint->m_Time >= deltaTime);
10984
}

MarathonRecompLib/config/Marathon.toml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -400,37 +400,37 @@ address = 0x821A03F0
400400
jump_address_on_true = 0x821A03FC
401401

402402
[[midasm_hook]]
403-
name = "FixTPJRopeHFR2BNE"
403+
name = "ObjTarzan_VolatileBranch"
404404
address = 0x8232D3E0
405-
jump_address_on_true = 0x8232D3E4
406405
registers = ["r30"]
406+
jump_address_on_true = 0x8232D3E4
407407

408408
[[midasm_hook]]
409-
name = "FixTPJRopeHFR3LFS"
409+
name = "ObjTarzan_PatchStaticDeltaTime"
410410
address = 0x8232D3E4
411-
registers = ["f0","r30"]
411+
registers = ["f0", "r30"]
412412
after_instruction = true
413413

414414
[[midasm_hook]]
415-
name = "FixTPJRopeHFR4LFS"
415+
name = "ObjTarzan_PatchStaticDeltaTime"
416416
address = 0x8232D49C
417-
registers = ["f1","f3"]
417+
registers = ["f1", "f3"]
418418
after_instruction = true
419419

420420
[[midasm_hook]]
421-
name = "FixTPJRopeHFR5LFS"
421+
name = "ObjTarzan_PatchStaticDeltaTime"
422422
address = 0x8232D530
423-
registers = ["f1","f3"]
423+
registers = ["f1", "f3"]
424424
after_instruction = true
425425

426426
[[midasm_hook]]
427-
name = "FixTPJRopeHFR6LFS"
427+
name = "ObjTarzan_PatchStaticDeltaTime"
428428
address = 0x8232D57C
429-
registers = ["f0","f3"]
429+
registers = ["f0", "f3"]
430430
after_instruction = true
431431

432432
[[midasm_hook]]
433-
name = "FixTPJRopeHFR7EXTRA"
433+
name = "ObjTarzan_PatchDeltaTimeArgument"
434434
address = 0x8232D818
435-
registers = ["f3","r4","r1"]
435+
registers = ["f3", "r4", "r1"]
436436

0 commit comments

Comments
 (0)