-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrenderDebug.asm
More file actions
355 lines (307 loc) · 5.47 KB
/
renderDebug.asm
File metadata and controls
355 lines (307 loc) · 5.47 KB
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
!Set Cull Mode within default colour drawer [Eon]
HOOK @ $8001a79C
{
li r3, 0
lis r12, 0x801f
ori r12, r12, 0x136c
mtctr r12
bctrl
lwz r0, 0x24(r1)
}
Custom RenderDebug Call
.alias ProcessPosition = 0
HOOK @ $8002DD24
{
ble %end%
cmplwi r0, 8
bgtlr
lwz r12, 0x3C(r3)
lwz r12, 0x58(r12)
mtctr r12
bctr
}
op cmpwi r29, 17 @ $8002e684
HOOK @ $8002E62C
{
cmplwi r29, ProcessPosition
beq %end%
rlwinm. r0, r0, 31,31,31
}
HOOK @ $8002E604
{
cmplwi r29, ProcessPosition
beq %end%
rlwinm. r0, r3, 27,31,31
}
HOOK @ $8002e610
{
cmplwi r29, ProcessPosition
mr r4, r29
blt %end%
li r4, 16
beq %end%
subi r4, r29, 1
}
HOOK @ $8002e638
{
cmplwi r29, ProcessPosition
mr r4, r29
blt %end%
li r4, 16
beq %end%
subi r4, r29, 1
}
HOOK @ $8002E5B4
{
subi r4, r29, 1
rlwimi r3, r4, 16, 8, 15
}
Frame Advance Convert
HOOK @ $8002E5C4
{
cmpwi r0, 2
bne original
DebugPause:
# cmpwi r26, 0
# beq %end%
cmpwi r29, 0
beq %end%
original:
slw. r0, r31, r29
}
#testCode
#.alias dpl = 0x0001
#.alias dpr = 0x0002
#.alias dpd = 0x0004
#.alias dpu = 0x0008
#.alias z = 0x0010
#.alias r = 0x0020
#.alias l = 0x0040
#.alias na = 0x0080
#.alias a = 0x0100
#.alias b = 0x0200
#.alias x = 0x0400
#.alias y = 0x0800
#.alias s = 0x1000
#.alias debuginput = l || 0x1
#
#CODE @ $8000000
#{
# word debuginput
#}
drawQuadOutline [Eon]
.macro callfunc(<addr>)
{
.alias temp_Hi = <addr> / 0x10000
.alias temp_Lo = <addr> & 0xFFFF
lis r12, temp_Hi
ori r12, r12, temp_Lo
mtctr r12
bctrl
}
HOOK @ $80541FB4
{
stwu r1, -0x50(r1)
mflr r0
stw r0, 0x54(r1)
stfd f31, 0x20(r1)
stfd f30, 0x28(r1)
word 0xf3e10030; // psq_st p31, 0x30(r1), 0, qr0
word 0xf3c10040; // psq_st p30, 0x40(r1), 0, qr0
fmr f30, f1
fmr f31, f2
stw r31, 0x1C(r1)
mr r31, r4
stw r30, 0x18(r1)
mr r30, r5
stw r29, 0x14(r1)
mr r29, r3
%callfunc(0x80019FA4)
%callfunc(0x80018DE4)
lwz r31, 0(r31)
%callfunc(0x8001A5C0)
#convert line width as double into line width as integer
lfs f0, -0x7B68(r2)
fmuls f0, f0, f30
fctiwz f0, f0
stfd f0, 0x8(r1)
lwz r3, 0xC(r1)
rlwinm r3, r3, 0, 24, 31
li r4, 2
%callfunc(0x801f12ac)
li r3, 0xB0 #line strip
li r4, 1
li r5, 5 #4 vertices
%callfunc(0x801F1088)
lis r3, 0xCC01 #gfx mem-loc
.macro drawVertex(<offset>)
{
lfs f0, <offset>(r29)
lfs f1, <offset>+0x4(r29)
stfs f0, -0x8000(r3) #x
stfs f1, -0x8000(r3) #y
stfs f31, -0x8000(r3) #z
stw r31, -0x8000(r3) #colour
}
#v0
%drawVertex(0x00)
#v1
%drawVertex(0x8)
#v2
%drawVertex(0x10)
#v3
%drawVertex(0x18)
#v0
%drawVertex(0x00)
#draws lines attaching each point
lfd f31, 0x20(r1)
lfd f30, 0x28(r1)
word 0xe3e10030; // psq_l p31, 0x30(r1), 0, qr0
word 0xe3c10040; // psq_l p30, 0x40(r1), 0, qr0
lwz r0, 0x54(r1)
lwz r31, 0x1C(r1)
lwz r30, 0x18(r1)
lwz r29, 0x14(r1)
mtlr r0
addi r1, r1, 0x50
blr
}
drawLine3D [Eon]
.macro callfunc(<addr>)
{
.alias temp_Hi = <addr> / 0x10000
.alias temp_Lo = <addr> & 0xFFFF
lis r12, temp_Hi
ori r12, r12, temp_Lo
mtctr r12
bctrl
}
HOOK @ $80541fb8
{
stwu r1, -0x50(r1)
mflr r0
stw r0, 0x54(r1)
stfd f31, 0x20(r1)
word 0xf3e10030; // psq_st p31, 0x30(r1), 0, qr0
fmr f31, f1
stw r31, 0x1C(r1) #pos1
mr r31, r3
stw r30, 0x18(r1) #pos2
mr r30, r4
stw r29, 0x14(r1) #colour
lwz r29, 0x0(r5)
stw r28, 0x10(r1) #zmode
mr r28, r6
%callfunc(0x80019FA4)
%callfunc(0x80018DE4)
%callfunc(0x8001A5C0)
#convert line width as double into line width as integer
lfs f0, -0x7B68(r2)
fmuls f0, f0, f31
fctiwz f0, f0
stfd f0, 0x8(r1)
lwz r3, 0xC(r1)
rlwinm r3, r3, 0, 24, 31
li r4, 2
%callfunc(0x801f12ac)
li r3, 0xA8 #line
li r4, 1
li r5, 2 #2 vertices
%callfunc(0x801F1088)
lis r3, 0xCC01 #gfx mem-loc
.macro drawVertex(<arg>)
{
lfs f0, 0x0(<arg>)
lfs f1, 0x4(<arg>)
lfs f2, 0x8(<arg>)
stfs f0, -0x8000(r3) #x
stfs f1, -0x8000(r3) #y
stfs f2, -0x8000(r3) #z
stw r29, -0x8000(r3) #colour
}
#v0
%drawVertex(31)
#v1
%drawVertex(30)
#draws line attaching each point
lfd f31, 0x20(r1)
word 0xe3e10030; // psq_l p31, 0x30(r1), 0, qr0
lwz r0, 0x54(r1)
lwz r31, 0x1C(r1)
lwz r30, 0x18(r1)
lwz r29, 0x14(r1)
lwz r28, 0x10(r1)
mtlr r0
addi r1, r1, 0x50
blr
}
DebugFileLoader [Eon]
.alias heapType = 0x9 #idkResource
HOOK @ $800B08A0
{
stwu r1, -0xB4(r1)
mflr r0
stw r0, 0xB8(r1)
lis r5, 0x8054
ori r5, r5, 0x8400
lbz r0, -1(r5)
cmpwi r0, 1
beq end
li r0, 1
stb r0, -1(r5)
addi r3, r1, 0x10
bl data
mflr r4
addi r4, r4, 0x10 #has to be adjusted appropriately if size of HOOK is odd or even
li r6, 0x0
li r7, 0x0
lis r12, 0x8002 # \
ori r12, r12, 0x239C # | Set up the read parameter block
mtctr r12 # |
bctrl # /
addi r3, r1, 0x10
lis r12, 0x8001 #readFile
ori r12, r12, 0xBF0C
mtctr r12
bctrl
#8000C8B8
li r3, 0x200
li r4, heapType
lis r12, 0x8000
ori r12, r12, 0xc8b8
mtctr r12
bctrl
#0x800696B4
lis r4, 0x8054
ori r4, r4, 0x8400
stw r3, 0x87C(r4)
li r4, 10
li r5, heapType
lis r12, 0x8006
ori r12, r12, 0x96b4
mtctr r12
bctrl
#0x8006b400
li r4, 0x400
li r5, 1
li r6, heapType
lis r12, 0x8006
ori r12, r12, 0xB400
mtctr r12
bctrl
lis r3, 0x8054
ori r3, r3, 0x2000
li r4, 1
stw r4, 0x20(r3)
end:
lwz r0, 0xB8(r1)
mtlr r0
addi r1, r1, 0xB4
blr
data:
blrl
}
.GOTO->skip
string "/../Source/Extras/DebugMode/debug.bin"
skip:
.RESET