-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCollision Manager Render Debug.asm
More file actions
474 lines (432 loc) · 7.19 KB
/
Collision Manager Render Debug.asm
File metadata and controls
474 lines (432 loc) · 7.19 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
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
renderDebug/[grCollisionManager]
#80059e60 melee stage draw
.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 @ $80112c94
{
stwu r1, -0x0020 (r1)
mflr r0
stw r0, 0x0024 (r1)
stw r31, 0x10(r1)
stw r30, 0x14(r1)
stw r29, 0x18(r1)
stw r28, 0x1C(r1)
mr r30, r3
#if stage render enabled, draw stuff, else end
li r3, 8
lis r12, 0x8054
ori r12, r12, 0x1F9C
mtctr r12
bctrl
cmpwi r3, 0
beq end
#lots of specific checks for if the collision is in use.
lwz r0, 0x40(r30)
rlwinm. r0, r0, 25, 31, 31
beq end
lis r29, 0x804A
subi r29, r29, 6788
lwz r31, 0x0004 (r29)
addi r29, r29, 4
b checkLoop
loopStart:
lbz r3, -0x4(r31)
rlwinm. r0, r3, 25, 31, 31
beq next
rlwinm. r0, r3, 31, 31, 31
bne next
subi r28, r31, 48
mr r3, r28
%callFunc(0x80541F90)
next:
lwz r31, 0(r31)
checkLoop:
cmplw r31, r29
bne loopStart
end:
lwz r31, 0x10(r1)
lwz r30, 0x14(r1)
lwz r29, 0x18(r1)
lwz r28, 0x1C(r1)
lwz r0, 0x24(r1)
mtlr r0
addi r1, r1, 0x20
blr
}
#drawCollisionList
HOOK @ $80541F90
{
.alias input = 23
stwu r1, -0x0050 (r1)
mflr r0
stw r0, 0x0054 (r1)
stmw r23, 0x2C(r1)
mr input, r3
lbz r5, 0x002C (r3)
rlwinm. r0, r5, 25, 31, 31
beq end
loopInit:
li r24, 0
li r30, 0
b loopNext
loop:
lwz r0, 0x0018(input)
add r31, r0, r30
lbz r0, 0x54(r31)
rlwinm. r0, r0, 26, 31, 31
beq loopIterate
li r25, 0
lhz r26, 0x2(r31)
b innerLoopCheck
innerLoopStart:
mr r3, r31
mr r4, r25
%callFunc(0x80112EA0) #getLine/[grCollisionJoint]
mr r27, r3
mr r3, input
addi r4, r1, 0x18
mr r5, r27
li r6, 0
%callFunc(0x80111968) #getSegment
addi r3, r1, 0x18
mr r4, r27
%callFunc(0x80541F94) #drawCollision
addi r25, r25, 1
innerLoopCheck:
cmplw r25, r26
blt innerLoopStart
loopIterate:
addi r30, r30, 96
addi r24, r24, 1
loopNext:
lhz r0, 0x0006 (input)
cmplw r24, r0
blt loop
end:
lmw r23, 0x2C(r1)
lwz r0, 0x0054(r1)
mtlr r0
addi r1, r1, 80
blr
}
#DrawCollision(SegmentData, CollisionData)
HOOK @ $80541F94
{
.alias SegmentData = 31
.alias CollisionData = 30
.alias dataBlock = 29
.alias flags = 3
.alias type = 4
.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
}
.macro storeColour(<offset>)
{
lbz r0, <offset>(dataBlock)
stb r0, 0x8(r1)
lbz r0, <offset>+1(dataBlock)
stb r0, 0x9(r1)
lbz r0, <offset>+2(dataBlock)
stb r0, 0xA(r1)
}
.macro storeAlpha(<offset>)
{
lbz r0, <offset>(dataBlock)
stb r0, 0xB(r1)
}
.alias notCollidableAlpha = 0x90
.alias superSoftAlpha = 0x91
.alias normalAlpha = 0x92
.alias passableFloorColour = 0x94
.alias solidFloorColour = 0x98
.alias ledgeColour = 0x9C
.alias ceilingColour = 0xA0
.alias nonWalljumpableWallColour = 0xA4
.alias walljumpableWallColour = 0xA8
.macro isntAssigned()
{
andi. r0, type, 0xF
}
.macro isFloor()
{
andi. r0, type, 0x01
}
.macro isCeiling()
{
andi. r0, type, 0x02
}
.macro isRightWall()
{
andi. r0, type, 0x04
}
.macro isLeftWall()
{
andi. r0, type, 0x08
}
.macro isDropThrough()
{
andi. r0, flags, 0x01
}
.macro isRotating()
{
andi. r0, flags, 0x04
}
.macro isSuperSoft()
{
andi. r0, flags, 0x08
}
.macro isLeftLedge()
{
andi. r0, flags, 0x20
}
.macro isRightLedge()
{
andi. r0, flags, 0x40
}
.macro isNonWalljump()
{
andi. r0, flags, 0x80
}
.macro isPlayerCollidable()
{
andi. r0, type, 0x10
}
.macro isItemCollidable()
{
andi. r0, type, 0x20
}
.macro isPTCollidable()
{
andi. r0, type, 0x40
}
.macro isSSECollidable()
{
andi. r0, type, 0x80
}
stwu r1, -0x0030 (r1)
mflr r0
stw r0, 0x0034(r1)
stw r31, 0x30(r1)
stw r30, 0x2C(r1)
stw r29, 0x28(r1)
mr SegmentData, r3
mr CollisionData, r4
#mem location of debug.bin
lis dataBlock, 0x8054
ori dataBlock, dataBlock, 0x8400
lbz flags, 0x10(CollisionData)
lbz type, 0xF(CollisionData)
%isntAssigned()
beq end #unassigned
assigned:
%isPlayerCollidable()
bne playerCollidable
notCollidable:
%setAlpha(notCollidableAlpha)
b startColours
playerCollidable:
%isSuperSoft()
bne superSoft
normal:
%storeAlpha(normalAlpha)
b startColours
superSoft:
%storeAlpha(superSoftAlpha)
b startColours
startColours:
testFloor:
%isFloor()
beq testCeiling
Floor:
%isLeftLedge()
beq checkRightLedge
#is a ledge, so calc positions to draw
lfs f3, -0x68DC(r2)
lfs f2, 0x0(SegmentData)
fadds f1, f2, f3
stfs f1, 0x10(r1)
fsubs f1, f2, f3
stfs f1, 0x18(r1)
lfs f2, 0x4(SegmentData)
fadds f1, f2, f3
stfs f1, 0x14(r1)
fsubs f1, f2, f3
stfs f1, 0x1C(r1)
b drawLedge
checkRightLedge:
%isRightLedge()
beq drawFloor
#is a ledge, so calc positions to draw
lfs f3, -0x68DC(r2)
lfs f2, 0x8(SegmentData)
fsubs f1, f2, f3
stfs f1, 0x10(r1)
fadds f1, f2, f3
stfs f1, 0x18(r1)
lfs f2, 0xC(SegmentData)
fadds f1, f2, f3
stfs f1, 0x14(r1)
fsubs f1, f2, f3
stfs f1, 0x1C(r1)
drawLedge:
%storeColour(ledgeColour)
lfs f1, -0x68CC(r2)
fadds f1, f1, f1
addi r3, r1, 0x10
addi r4, r1, 0x08
li r5, 0
%callFunc(0x80041104)
drawFloor:
%isDropThrough()
beq solid
passable:
%storeColour(passableFloorColour)
b draw
solid:
%storeColour(solidFloorColour)
b draw
testCeiling:
%isCeiling()
beq testWall
ceiling:
%storeColour(ceilingColour)
b draw
testWall:
%isLeftWall()
bne wall
%isRightWall()
beq draw
wall:
%isNonWalljump()
beq walljumpableWall
nonWalljumpableWall:
%storeColour(nonWalljumpableWallColour)
b draw
walljumpableWall:
%storeColour(walljumpableWallColour)
draw:
lfs f1, -0x68CC(r2)
mr r3, SegmentData
addi r4, r1, 8
li r5, 0
%callFunc(0x80041104)
end:
lwz r31, 0x30(r1)
lwz r30, 0x2C(r1)
lwz r29, 0x28(r1)
lwz r0, 0x34 (r1)
mtlr r0
addi r1, r1, 0x30
blr
}
Fully transparent Shapes arent drawn are not attempted to be drawn [Eon]
#clSegment
HOOK @ $80041130
{
mr r29, r3
lbz r0, 0x3(r4)
cmpwi r0, 0
bne %end%
lis r12, 0x8004
ori r12, r12, 0x11F4
mtctr r12
bctr
}
#clRect
HOOK @ $80041F80
{
#if transparent, skip to end
mr r31, r3
lbz r0, 0x3(r4)
cmpwi r0, 0
bne %end%
end:
lis r12, 0x8004
ori r12, r12, 0x2020
mtctr r12
bctr
}
#clCircle
HOOK @ $80041634
{
mr r27, r5
lbz r0, 0x3(r4)
cmpwi r0, 0
bne %end%
lis r12, 0x8004
ori r12, r12, 0x183C
mtctr r12
bctr
}
#clTriangle
HOOK @ $800428F8
{
#if transparent, skip to end
mr r31, r3
lbz r0, 0x3(r4)
cmpwi r0, 0
bne %end%
end:
lis r12, 0x8004
ori r12, r12, 0x2984
mtctr r12
bctr
}
clRectangle and gfAreaTriangle draws correct [Eon]
.macro drawPart(<a>, <b>, <c>, <d>, <r>)
{
lfs f2, <a>(<r>)
lfs f3, <b>(<r>)
lfs f4, <c>(<r>)
lfs f5, <d>(<r>)
stfs f2, 0x20(r1)
stfs f3, 0x24(r1)
stfs f4, 0x28(r1)
stfs f5, 0x2C(r1)
lfs f1, -0x68CC(r2)
addi r3, r1, 0x20
addi r4, r1, 0x10
li r5, 0
lis r12, 0x8004
ori r12, r12, 0x1104
mtctr r12
bctrl
}
HOOK @ $80041F84
{
lwz r0, 0x0(r4)
stw r0, 0x10(r1)
%drawPart(0x0, 0x4, 0x0, 0xC, 31)
%drawPart(0x0, 0xC, 0x8, 0xC, 31)
%drawPart(0x8, 0xC, 0x8, 0x4, 31)
%drawPart(0x8, 0x4, 0x0, 0x4, 31)
lis r12, 0x8004
ori r12, r12, 0x2020
mtctr r12
bctr
}
HOOK @ $800428FC
{
lwz r0, 0x0(r4)
stw r0, 0x10(r1)
%drawPart(0x0, 0x4, 0x8, 0xC, 31)
%drawPart(0x8, 0xC, 0x10, 0x14, 31)
%drawPart(0x10, 0x14, 0x0, 0x4, 31)
lis r12, 0x8004
ori r12, r12, 0x2984
mtctr r12
bctr
}