Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
battle_heap_create_obfuscated.c File Reference

Go to the source code of this file.

Functions

void battle_heap_create_obfuscated (void)
 

Variables

s32 obfuscated_battle_heap_create []
 

Function Documentation

◆ battle_heap_create_obfuscated()

void battle_heap_create_obfuscated ( void )

Definition at line 13 of file battle_heap_create_obfuscated.c.

13 {
14 s32(*readFunc)(OSPiHandle*, u32, u32*) = osEPiReadIo;
15 s32 seed = 0x33F50000;
16 s32 (*battle_heap_create)(void) = (s32 (*) (void)) obfuscated_battle_heap_create;
17 u32 hash = 0;
18 u32 thisInsn;
19 u32* it;
20 u32 prevInsn;
21
22 readFunc(nuPiCartHandle, 0xB0000800, &thisInsn);
23 seed -= thisInsn;
24
25 prevInsn = 0;
26
27 for (it = (u32*) general_heap_create_obfuscated_ROM_START; it < (u32*) general_heap_create_obfuscated_ROM_END; it++) {
28 readFunc(nuPiCartHandle, (u32) it, &thisInsn);
29 hash += LOWER(thisInsn) + UPPER(thisInsn);
30
31 if (OPCODE(prevInsn) == LUI && (OPCODE(thisInsn) == ADDIU || OPCODE(thisInsn) == LW)) {
32 if (GET_RS(thisInsn) == GET_RT(prevInsn) && GET_RS(thisInsn) == GET_RT(thisInsn)) {
33 hash -= LOWER(thisInsn);
34 hash -= LOWER(prevInsn);
35 }
36 }
37
38 if (OPCODE(thisInsn) == JAL) {
39 hash -= LOWER(thisInsn) + (UPPER(thisInsn) & 0xFC00);
40 }
41
42 prevInsn = thisInsn;
43 }
44
45 battle_heap_create += seed + 0x291993 - hash;
46
47 // If the function's address is 0x8XXXXXXX
48 if (((u32)battle_heap_create >> 0x1C) == 8) {
50 } else {
52 }
53}
s32 obfuscated_battle_heap_create[]
s32 battle_heap_create(void)
Definition heap.c:22
HeapNode * _heap_create(HeapNode *addr, u32 size)
Definition 43F0.c:63
#define ADDIU
Definition mips.h:5
#define LOWER(x)
Definition mips.h:8
#define GET_RS(x)
Definition mips.h:11
#define UPPER(x)
Definition mips.h:9
#define JAL
Definition mips.h:4
#define GET_RT(x)
Definition mips.h:12
#define LW
Definition mips.h:7
#define OPCODE(x)
Definition mips.h:10
#define LUI
Definition mips.h:6
HeapNode heap_battleHead

Referenced by shim_battle_heap_create_obfuscated().

Variable Documentation

◆ obfuscated_battle_heap_create

s32 obfuscated_battle_heap_create[]
extern