-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathSPHERES.MIP
611 lines (573 loc) · 11.5 KB
/
SPHERES.MIP
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
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
opt at-,w-,c+,m-
SECTION ASM
INCLUDE SPEC_PSX/GLOBAL.INC
XDEF GetJointAbsPosition, IsRoomOutside, GetSpheres
XREF mTranslateAbsXYZ, meshes, GetBestFrame, IsRoomOutsideNo, OutsideRoomTable, GetCeiling, GetHeight, room, OutsideRoomOffsets, GetFloor, bones, Matrix, GetFrames, mPushUnitMatrix, mSetTrans, mRotYXZ, mTranslateXYZ, mRotSuperPackedYXZ, mPopMatrix, mPushMatrix, mRotY, mCopyMatrix, iTranslateXYZ, InterpolateMatrix, iRotZ, mRotZ, iRotX, mRotX, iRotY, mRotY, InitInterpolation, iTranslateXYZ2, iRotSuperPackedYXZ, iPopMatrix, iPushMatrix, objects, iMatrixStack
GetSpheres:
bnez a0, loc_8E448
move v0, zero
jr ra
nop
loc_8E448:
addiu sp, -0x50
sw s0, 0x50-0x28(sp)
sw s1, 0x50-0x24(sp)
sw s2, 0x50-0x20(sp)
sw s3, 0x50-0x1C(sp)
sw s4, 0x50-0x18(sp)
sw s5, 0x50-0x14(sp)
sw s6, 0x50-0x10(sp)
sw s7, 0x50-0xC(sp)
sw fp, 0x50-0x8(sp)
sw ra, 0x50-0x4(sp)
sw a2, 0x50-0x34(sp)
move s1, a0
andi at, a2, 1
beqz at, loc_8E4AC
move s4, a1
lw s3, 0x44(s1)
lw fp, 0x40(s1)
jal mPushUnitMatrix
lw s7, 0x48(s1)
move a0, zero
move a1, zero
move a2, zero
jal mSetTrans
addiu ra, 0x20
loc_8E4AC:
move s7, zero
jal mPushMatrix
move s3, zero
lw a0, 0x40(s1)
lw a1, 0x44(s1)
lw a2, 0x48(s1)
jal mTranslateAbsXYZ
move fp, zero
lh a0, 0x4E(s1)
lh a1, 0x4C(s1)
jal mRotYXZ
lh a2, 0x50(s1)
jal GetBestFrame
move a0, s1
move s0, v0
lh a0, 0xC(s0)
lh a1, 0xE(s0)
lh a2, 0x10(s0)
jal mTranslateXYZ
addiu s0, 0x12
addiu a0, sp, 0x50-0x40
move a1, zero
jal mRotSuperPackedYXZ
sw s0, 0x50-0x40(sp)
lh v1, 0xC(s1)
la s5, objects
sll v1, 6
addu s5, v1
lh v0, 2(s5)
lw v1, meshes-GP_ADDR(gp)
sll v0, 2
addu s6, v1, v0
lw v0, 4(s5)
lw v1, bones-GP_ADDR(gp)
lw s0, 0(s6)
sll v0, 2
jal mPushMatrix
addu s2, v1, v0
lw at, 0x50-0x34(sp)
nop
andi at, 2
bnez at, loc_8E568
lh a0, 0(s0)
lh a1, 2(s0)
lh a2, 4(s0)
jal mTranslateXYZ
loc_8E568:
addiu s6, 8
cfc2 t4, r5
cfc2 t5, r6
cfc2 t6, r7
lh v1, 6(s0)
addu t4, fp
addu t5, s3
addu t6, s7
sw t4, 0(s4)
sw t5, 4(s4)
sw t6, 8(s4)
sw v1, 0xC(s4)
jal mPopMatrix
addiu s4, 0x10
lh at, 0(s5)
lw s1, 0x3C(s1)
addiu s5, at, -1
blez s5, loc_8E6C0
sw at, 0x50-0x38(sp)
loc_8E5B4:
lw s0, 0(s2)
nop
andi v0, s0, 1
beqz v0, loc_8E5D0
addiu s2, 4
jal mPopMatrix
nop
loc_8E5D0:
andi v0, s0, 2
beqz v0, loc_8E5E4
nop
jal mPushMatrix
nop
loc_8E5E4:
lw a0, 0(s2)
lw a1, 4(s2)
jal mTranslateXYZ
lw a2, 8(s2)
addiu a0, sp, 0x50-0x40
jal mRotSuperPackedYXZ
move a1, zero
beqz s1, loc_8E654
andi v0, s0, 0x1C
beqz v0, loc_8E654
andi v0, s0, 8
beqz v0, loc_8E628
andi v0, s0, 4
lh a0, 0(s1)
jal mRotY
addiu s1, 2
andi v0, s0, 4
loc_8E628:
beqz v0, loc_8E640
andi v0, s0, 0x10
lh a0, 0(s1)
jal mRotX
addiu s1, 2
andi v0, s0, 0x10
loc_8E640:
beqz v0, loc_8E654
nop
lh a0, 0(s1)
jal mRotZ
addiu s1, 2
loc_8E654:
lw s0, 0(s6)
jal mPushMatrix
addiu s6, 8
lw at, 0x50-0x34(sp)
nop
andi at, 2
bnez at, loc_8E680
lh a0, 0(s0)
lh a1, 2(s0)
lh a2, 4(s0)
jal mTranslateXYZ
loc_8E680:
addiu s5, -1
cfc2 t4, r5
cfc2 t5, r6
cfc2 t6, r7
lh v1, 6(s0)
addu t4, fp
addu t5, s3
addu t6, s7
sw t4, 0(s4)
sw t5, 4(s4)
sw t6, 8(s4)
sw v1, 0xC(s4)
jal mPopMatrix
addiu s2, 0xC
bgtz s5, loc_8E5B4
addiu s4, 0x10
loc_8E6C0:
jal mPopMatrix
nop
lw v0, 0x50-0x38(sp)
lw ra, 0x50-0x4(sp)
lw fp, 0x50-0x8(sp)
lw s7, 0x50-0xC(sp)
lw s6, 0x50-0x10(sp)
lw s5, 0x50-0x14(sp)
lw s4, 0x50-0x18(sp)
lw s3, 0x50-0x1C(sp)
lw s2, 0x50-0x20(sp)
lw s1, 0x50-0x24(sp)
lw s0, 0x50-0x28(sp)
jr ra
addiu sp, 0x50
IsRoomOutside:
addiu sp, -0x38
sw s3, 0x38-0xC(sp)
move s3, a0
sw s2, 0x38-0x10(sp)
move s2, a1
sw s4, 0x38-0x8(sp)
move s4, a2
sra v1, s3, 12
sra a0, s4, 12
sll v0, v1, 3
subu v0, v1
sll v0, 2
subu v0, v1
addu v0, a0
lw v1, OutsideRoomOffsets-GP_ADDR(gp)
sll v0, 1
sw ra, 0x38-0x4(sp)
sw s1, 0x38-0x14(sp)
bgez s3, loc_8EF54
sw s0, 0x38-0x18(sp)
bltz s4, loc_8F11C
loc_8EF54:
addu v0, v1
lh v1, 0(v0)
li v0, 0xFFFFFFFF
beq v1, v0, loc_8F11C
andi t0, v1, 0x7FFF
bgez v1, loc_8EFF4
sll v0, t0, 2
addu v0, t0
lw v1, room-GP_ADDR(gp)
sll v0, 4
addu s1, v1, v0
lw v0, 0x24(s1)
lw v1, 0x20(s1)
slt at, s2, v0
bnez at, loc_8F11C
slt at, v1, s2
bnez at, loc_8F11C
lw v1, 0x1C(s1)
lh v0, 0x28(s1)
addiu at, v1, 0x400
slt at, s4, at
bnez at, loc_8F11C
addiu v0, -1
sll v0, 10
addu v0, v1, v0
slt v0, v0, s4
bnez v0, loc_8F11C
lw v1, 0x14(s1)
lh v0, 0x2A(s1)
addiu at, v1, 0x400
slt at, s3, at
bnez at, loc_8F11C
addiu v0, -1
sll v0, 10
addu v0, v1, v0
slt v0, v0, s3
bnez v0, loc_8F11C
nop
j loc_8F07C
move v0, t0
loc_8EFF4:
lw v0, OutsideRoomTable-GP_ADDR(gp)
j loc_8F108
addu a0, v0, v1
loc_8F000:
addu v0, t0
lw v1, room-GP_ADDR(gp)
sll v0, 4
addu s1, v1, v0
lw v0, 0x24(s1)
lw v1, 0x20(s1)
slt at, s2, v0
bnez at, loc_8F104
slt at, v1, s2
bnez at, loc_8F104
lw v1, 0x1C(s1)
lh v0, 0x28(s1)
addiu at, v1, 0x400
slt at, s4, at
bnez at, loc_8F104
addiu v0, -1
sll v0, 10
addu v0, v1, v0
slt v0, v0, s4
bnez v0, loc_8F104
lw v1, 0x14(s1)
lh v0, 0x2A(s1)
addiu at, v1, 0x400
slt at, s3, at
bnez at, loc_8F104
addiu v0, -1
sll v0, 10
addu v0, v1, v0
slt v0, v0, s3
bnez v0, loc_8F104
andi v0, t0, 0xFF
loc_8F07C:
move a1, s2
move a0, s3
move a2, s4
addiu a3, sp, 0x38-0x28
sh v0, 0x38-0x28(sp)
jal GetFloor
sh v0, IsRoomOutsideNo-GP_ADDR(gp)
move s0, v0
move a0, s0
move a1, s3
move a2, s2
jal GetHeight
move a3, s4
move v1, v0
li v0, 0xFFFF8100
beq v1, v0, loc_8F11C
slt v0, v1, s2
bnez v0, loc_8F120
li v0, 0xFFFFFFFE
move a0, s0
move a1, s3
move a2, s2
jal GetCeiling
move a3, s4
slt v0, s2, v0
bnez v0, loc_8F11C
nop
lhu v1, 0x4E(s1)
nop
andi v1, 0x21
bnez v1, loc_8F120
li v0, 1
j loc_8F120
li v0, 0xFFFFFFFD
loc_8F104:
addiu a0, 1
loc_8F108:
lbu t0, 0(a0)
li v0, 0xFF
andi v1, t0, 0xFF
bne v1, v0, loc_8F000
sll v0, t0, 2
loc_8F11C:
li v0, 0xFFFFFFFE
loc_8F120:
lw ra, 0x38-0x4(sp)
lw s4, 0x38-0x8(sp)
lw s3, 0x38-0xC(sp)
lw s2, 0x38-0x10(sp)
lw s1, 0x38-0x14(sp)
lw s0, 0x38-0x18(sp)
jr ra
addiu sp, 0x38
GetJointAbsPosition:
addiu sp, -0x50
sw s4, 0x50-0x10(sp)
sw s5, 0x50-0xC(sp)
sw s6, 0x50-0x8(sp)
sw ra, 0x50-0x4(sp)
move s5, a0
move s4, a1
addiu a1, sp, 0x50-0x38
move s6, a2
sw s3, 0x50-0x14(sp)
sw s2, 0x50-0x18(sp)
sw s1, 0x50-0x1C(sp)
sw s0, 0x50-0x20(sp)
lh v1, 0xC(s5)
la s1, objects
sll v1, 6
addu s1, v1
lw v0, Matrix-GP_ADDR(gp)
addiu a2, sp, 0x50-0x30
jal GetFrames
sw v0, 0x50-0x24(sp)
jal mPushUnitMatrix
move s0, v0
move a0, zero
move a1, zero
jal mSetTrans
move a2, zero
lh a0, 0x4E(s5)
lh a1, 0x4C(s5)
jal mRotYXZ
lh a2, 0x50(s5)
lw s2, 0x3C(s5)
lw v0, 4(s1)
lw v1, bones-GP_ADDR(gp)
sll v0, 2
bnez s0, loc_8E9EC
addu s3, v1, v0
lw v0, 0x50-0x38(sp)
nop
lh a0, 0xC(v0)
lh a1, 0xE(v0)
lh a2, 0x10(v0)
addiu v0, 0x12
jal mTranslateXYZ
sw v0, 0x50-0x2C(sp)
addiu a0, sp, 0x50-0x2C
jal mRotSuperPackedYXZ
move a1, zero
blez s6, loc_8E9D8
move s1, s6
loc_8E92C:
lw s0, 0(s3)
nop
andi v0, s0, 1
beqz v0, loc_8E94C
andi v0, s0, 2
jal mPopMatrix
nop
andi v0, s0, 2
loc_8E94C:
beqz v0, loc_8E95C
nop
jal mPushMatrix
nop
loc_8E95C:
lw a0, 4(s3)
lw a1, 8(s3)
jal mTranslateXYZ
lw a2, 0xC(s3)
addiu a0, sp, 0x50-0x2C
jal mRotSuperPackedYXZ
move a1, zero
beqz s2, loc_8E9CC
andi v0, s0, 0x1C
beqz v0, loc_8E9CC
andi v0, s0, 8
beqz v0, loc_8E9A0
andi v0, s0, 4
lh a0, 0(s2)
jal mRotY
addiu s2, 2
andi v0, s0, 4
loc_8E9A0:
beqz v0, loc_8E9B8
andi v0, s0, 0x10
lh a0, 0(s2)
jal mRotX
addiu s2, 2
andi v0, s0, 0x10
loc_8E9B8:
beqz v0, loc_8E9CC
nop
lh a0, 0(s2)
jal mRotZ
addiu s2, 2
loc_8E9CC:
addiu s1, -1
bnez s1, loc_8E92C
addiu s3, 0x10
loc_8E9D8:
lw a0, 0(s4)
lw a1, 4(s4)
lw a2, 8(s4)
jal mTranslateXYZ
addiu ra, 0x170
loc_8E9EC:
la a2, iMatrixStack+0x200
lw a1, 0x50-0x30(sp)
jal InitInterpolation
move a0, s0
lw v1, 0x50-0x38(sp)
lw t0, 0x50-0x34(sp)
addiu v0, v1, 0x12
sw v0, 0x50-0x2C(sp)
addiu v0, t0, 0x12
sw v0, 0x50-0x28(sp)
lh a0, 0xC(v1)
lh a1, 0xE(v1)
lh a2, 0x10(v1)
lh a3, 0xC(t0)
lh v0, 0xE(t0)
lh v1, 0x10(t0)
sw v0, 0x50-0x40(sp)
jal iTranslateXYZ2
sw v1, 0x50-0x3C(sp)
addiu a0, sp, 0x50-0x2C
jal mRotSuperPackedYXZ
move a1, zero
addiu a0, sp, 0x50-0x28
jal iRotSuperPackedYXZ
move a1, zero
blez s6, loc_8EB38
move s1, s6
loc_8EA5C:
lw s0, 0(s3)
nop
andi v0, s0, 1
beqz v0, loc_8EA7C
andi v0, s0, 2
jal iPopMatrix
nop
andi v0, s0, 2
loc_8EA7C:
beqz v0, loc_8EA8C
nop
jal iPushMatrix
nop
loc_8EA8C:
lw a0, 4(s3)
lw a1, 8(s3)
jal iTranslateXYZ
lw a2, 0xC(s3)
addiu a0, sp, 0x50-0x2C
jal mRotSuperPackedYXZ
move a1, zero
addiu a0, sp, 0x50-0x28
jal iRotSuperPackedYXZ
move a1, zero
beqz s2, loc_8EB2C
andi v0, s0, 0x1C
beqz v0, loc_8EB2C
andi v0, s0, 8
beqz v0, loc_8EAE8
andi v0, s0, 4
lh a0, 0(s2)
jal mRotY
nop
lh a0, 0(s2)
jal iRotY
addiu s2, 2
andi v0, s0, 4
loc_8EAE8:
beqz v0, loc_8EB0C
andi v0, s0, 0x10
lh a0, 0(s2)
jal mRotX
nop
lh a0, 0(s2)
jal iRotX
addiu s2, 2
andi v0, s0, 0x10
loc_8EB0C:
beqz v0, loc_8EB2C
nop
lh a0, 0(s2)
jal mRotZ
nop
lh a0, 0(s2)
jal iRotZ
addiu s2, 2
loc_8EB2C:
addiu s1, -1
bnez s1, loc_8EA5C
addiu s3, 0x10
loc_8EB38:
lw a0, 0(s4)
lw a1, 4(s4)
jal iTranslateXYZ
lw a2, 8(s4)
jal InterpolateMatrix
nop
cfc2 t0, r5
cfc2 t1, r6
cfc2 t2, r7
lw at, 0x40(s5)
lw v0, 0x44(s5)
lw v1, 0x48(s5)
lw a0, 0x50-0x24(sp)
addu at, t0
addu v0, t1
addu v1, t2
sw at, 0(s4)
sw v0, 4(s4)
sw v1, 8(s4)
jal mCopyMatrix
sw a0, Matrix-GP_ADDR(gp)
lw ra, 0x50-0x4(sp)
lw s6, 0x50-0x8(sp)
lw s5, 0x50-0xC(sp)
lw s4, 0x50-0x10(sp)
lw s3, 0x50-0x14(sp)
lw s2, 0x50-0x18(sp)
lw s1, 0x50-0x1C(sp)
lw s0, 0x50-0x20(sp)
jr ra
addiu sp, 0x50