Skip to content

Commit 5efa553

Browse files
committed
Restore HUD Colors Code
Signed-off-by: Isaac Marovitz <isaacryu@icloud.com>
1 parent 3bb0a79 commit 5efa553

3 files changed

Lines changed: 102 additions & 0 deletions

File tree

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,88 @@
1+
#include <api/Marathon.h>
2+
#include <user/config.h>
13
#include <user/achievement_manager.h>
24

35
// TODO (Hyper): implement achievements menu.
46
void AchievementManagerUnlockMidAsmHook(PPCRegister& id)
57
{
68
AchievementManager::Unlock(id.u32);
79
}
10+
11+
void ContextualHUD_Init()
12+
{
13+
auto base = g_memory.base;
14+
15+
static bool Contextual_init;
16+
if (Contextual_init) return;
17+
18+
PPC_STORE_U32(0x82036BE4, 0x0); // Sonic
19+
PPC_STORE_U32(0x82036BE8, 0x3F800000); // Shadow
20+
PPC_STORE_U32(0x82036BFC, 0x3F800000); // E-123 Omega
21+
PPC_STORE_U32(0x82036C00, 0x3F800000); // Rouge
22+
PPC_STORE_U32(0x82036BEC, 0x3F800000); // Silver
23+
PPC_STORE_U32(0x82036BF4, 0x3F800000); // Amy
24+
PPC_STORE_U32(0x82036C04, 0x3F800000); // Blaze
25+
26+
Contextual_init = true;
27+
}
28+
29+
void ContextualHUD_LIFE_BER_ANIME_1(PPCRegister& str, PPCRegister& hud)
30+
{
31+
if (!Config::RestoreHUDColors) {
32+
return;
33+
}
34+
35+
ContextualHUD_Init();
36+
37+
enum {
38+
Sonic,
39+
Shadow,
40+
Silver,
41+
42+
Tails,
43+
Amy,
44+
Knuckles,
45+
46+
Omega,
47+
Rouge,
48+
Blaze
49+
50+
};
51+
52+
auto base = g_memory.base;
53+
auto chr_index = PPC_LOAD_U32(hud.u32 + 0x78);
54+
55+
uint32_t chr_in = str.u32;
56+
57+
switch (chr_index) {
58+
case Sonic:
59+
case Tails:
60+
case Knuckles:
61+
chr_in = 0x82036778; // sonic_in
62+
break;
63+
case Shadow:
64+
case Omega:
65+
case Rouge:
66+
chr_in = 0x8203676C; // shadow_in
67+
break;
68+
case Silver:
69+
case Amy:
70+
case Blaze:
71+
chr_in = 0x82036760; // silver_in
72+
break;
73+
}
74+
75+
str.u32 = chr_in;
76+
printf("chr_in:%x\n", chr_in);
77+
}
78+
79+
void ContextualHUD_RING_1(PPCRegister& index, PPCRegister& hud)
80+
{
81+
if (!Config::RestoreHUDColors) {
82+
return;
83+
}
84+
85+
auto base = g_memory.base;
86+
auto chr_index = PPC_LOAD_U32(hud.u32 + 0x78);
87+
index.u32 = chr_index;
88+
}

MarathonRecomp/user/config_def.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,5 +81,6 @@ CONFIG_DEFINE_HIDDEN("Codes", bool, HUDToggleKey, false);
8181
CONFIG_DEFINE_HIDDEN("Codes", bool, SkipIntroLogos, false);
8282
CONFIG_DEFINE_HIDDEN("Codes", bool, UseOfficialTitleOnTitleBar, false);
8383
CONFIG_DEFINE_HIDDEN("Codes", bool, DisableLowResolutionFontOnCustomUI, false);
84+
CONFIG_DEFINE_HIDDEN("Codes", bool, RestoreHUDColors, false);
8485

8586
CONFIG_DEFINE("Update", time_t, LastChecked, 0);

MarathonRecompLib/config/Marathon.toml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,3 +128,23 @@ registers = ["r10", "r24"]
128128
name = "RenderCsdCastMidAsmHook"
129129
address = 0x828C8FFC
130130
registers = ["r4"]
131+
132+
[[midasm_hook]]
133+
name = "ContextualHUD_LIFE_BER_ANIME_1"
134+
address = 0x824D8044
135+
registers = ["r5","r31"]
136+
137+
[[midasm_hook]]
138+
name = "ContextualHUD_LIFE_BER_ANIME_1"
139+
address = 0x824D80A0
140+
registers = ["r5","r31"]
141+
142+
[[midasm_hook]]
143+
name = "ContextualHUD_LIFE_BER_ANIME_1"
144+
address = 0x824D8F2C
145+
registers = ["r5","r31"]
146+
147+
[[midasm_hook]]
148+
name = "ContextualHUD_RING_1"
149+
address = 0x824DEB38
150+
registers = ["r5","r31"]

0 commit comments

Comments
 (0)