Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
load_obfuscation_shims.c
Go to the documentation of this file.
1#include "common.h"
2#include "nu/nusys.h"
3#include "ld_addrs.h"
4#include "mips.h"
5
8
9#if VERSION_JP
10// TODO: split these segments
15#endif
16
17#ifdef SHIFT
18void load_obfuscation_shims(void) {
19 // no-op since in shiftable builds, we bypass the obfuscation
20}
21#else
23 s32 (*readFunc)(OSPiHandle*, u32, u32*);
24 s32 (*readFunc2)(OSPiHandle*, u32, u32*);
27 s32 seed;
28 u32 hash;
32 u8* it;
33
34 // vramDest
36 seed = 0x0B112D28;
37 hash = 0;
38 readFunc(nuPiCartHandle, 0xB0000D10, &thisInsn);
39 seed -= thisInsn;
40 prevInsn = 0;
41
45
46 if (OPCODE(prevInsn) == LUI && (OPCODE(thisInsn) == ADDIU || OPCODE(thisInsn) == LW)) {
50 }
51 }
52
53 if (OPCODE(thisInsn) == JAL) {
54 hash -= LOWER(thisInsn) + (UPPER(thisInsn) & 0xFC00);
55 }
56
58 }
59 vramDest += seed + 0x2A4EB6 - hash;
60
61 // romStart
63 seed = 0x18F414AB;
64 hash = 0;
65 readFunc2(nuPiCartHandle, 0xB0000E38, &thisInsn2);
66 seed -= thisInsn2;
67 prevInsn = 0;
68
72
73 if (OPCODE(prevInsn) == LUI && (OPCODE(thisInsn2) == ADDIU || OPCODE(thisInsn2) == LW)) {
77 }
78 }
79
80 if (OPCODE(thisInsn2) == JAL) {
81 hash -= LOWER(thisInsn2) + (UPPER(thisInsn2) & 0xFC00);
82 }
84 }
85 romStart += seed + 0xED41C - hash;
86
88}
89#endif
BSS s32 PopupMenu_SelectedIndex
u32 dma_copy(Addr romStart, Addr romEnd, void *vramDest)
Definition 43F0.c:443
void load_obfuscation_shims(void)
s8 obfuscated_obfuscation_shims_VRAM[]
s8 obfuscated_obfuscation_shims_ROM_START[]
#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
u8 Addr[]
Linker symbol address, as in ld_addrs.h.
Definition types.h:16