-
Notifications
You must be signed in to change notification settings - Fork 2
/
systemHook.s
139 lines (126 loc) · 2.14 KB
/
systemHook.s
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
.include "r5900_regs.h"
.set noreorder
.global j_defhandler
.extern dump_memory
.extern jal_cheat
.section .resident, "a" # really gay that i have to compile this specific part at 0x00080000!!
.global systemHook
.ent systemHook
systemHook:
addiu $sp, $sp, -240
sq $ra, 0($sp)
sq $s0, 16($sp)
sq $s1, 32($sp)
sq $s2, 48($sp)
sq $s3, 64($sp)
sq $s4, 80($sp)
sq $s5, 96($sp)
sq $s6, 112($sp)
sq $s7, 128($sp)
sq $a0, 144($sp)
sq $a1, 160($sp)
sq $a2, 176($sp)
sq $v0, 192($sp)
sq $v1, 208($sp)
# --- FOR CHEATING ---
li $v0, 0x001bfa68
li $v1, 0x0c0655f4
sw $v1, _orig_jal
lw $v1, jal_cheats
#li $v1, 0x00090000
sw $v1, 0($v0)
# --- FOR CHEATING ---
lq $v1, 208($sp)
lq $v0, 192($sp)
lq $a2, 176($sp)
lq $a1, 160($sp)
lq $a0, 144($sp)
lq $s7, 128($sp)
lq $s6, 112($sp)
lq $s5, 96($sp)
lq $s4, 80($sp)
lq $s3, 64($sp)
lq $s2, 48($sp)
lq $s1, 32($sp)
lq $s0, 16($sp)
lq $ra, 0($sp)
addiu $sp, $sp, 240
j_defhandler:
nop
nop
jr $ra
nop
.end systemHook
.global readPad
.ent readPad
readPad:
addiu $sp, $sp, -240
sq $ra, 0($sp)
sq $s0, 16($sp)
sq $s1, 32($sp)
sq $s2, 48($sp)
sq $s3, 64($sp)
sq $s4, 80($sp)
sq $s5, 96($sp)
sq $s6, 112($sp)
sq $s7, 128($sp)
sq $a0, 144($sp)
sq $a1, 160($sp)
sq $a2, 176($sp)
sq $v0, 192($sp)
sq $v1, 208($sp)
# -- read joker --
lui $t7, 0x0044
lh $t8, 0xd81c($t7)
# -- read joker --
# L2 + RIGHT
addiu $t7, $zero, 0xFEDF
bne $t7, $t8, end
nop
# DI
mfc0 $v1, $12
lui $v0, 0x0001
and $v1, $v1, $v0
daddu $a0, $zero, $zero
beq $v1, $zero, end
sltu $a1, $zero, $v1
lui $v0, 0x0001
nop
loop:
di
sync.p
mfc0 $v1, $12
nop
and $v1, $v1, $v0
nop
bne $v1, $zero, loop
nop
daddu $a0, $a1, $zero
#jal dump_memory
nop
# EI
mfc0 $v0, $12
lui $v1, 0x0001
and $v0, $v0, $v1
ei
end:
lq $v1, 208($sp)
lq $v0, 192($sp)
lq $a2, 176($sp)
lq $a1, 160($sp)
lq $a0, 144($sp)
lq $s7, 128($sp)
lq $s6, 112($sp)
lq $s5, 96($sp)
lq $s4, 80($sp)
lq $s3, 64($sp)
lq $s2, 48($sp)
lq $s1, 32($sp)
lq $s0, 16($sp)
_orig_jal:
nop
nop
lq $ra, 0($sp)
jr $ra
addiu $sp, $sp, 240
.end readPad