-
Notifications
You must be signed in to change notification settings - Fork 44
/
BUBBLES.MIP
616 lines (574 loc) · 11.6 KB
/
BUBBLES.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
612
613
614
615
616
opt at-,w-,c+,m-
SECTION ASM
INCLUDE SPEC_PSX/GLOBAL.INC
XDEF SetInventoryLighting, DEL_ApplyMatrixSV, TriggerDynamic, DrawMonoScreen, CalcClipWindow_ONGTE, DrawFlash, DrawPsxTile, insert_psx_clip_window, PrintAllOtherObjects_ASM, print_all_object_NOW
XREF dynamics, LightPos, CamGTE, camera, number_dynamics, ClutStartY, lara_item, draw_rooms, number_draw_rooms, phd_PutPolygons, phd_bottom, phd_left, phd_top, room, objects, mPopMatrix, FlashFadeR, S_CalculateLight, effects, meshes, FlashFader, FlashFadeG, duff_item, FlashFadeB, db, SetDefDrawEnv, SetDrawEnv, items, CalcAllAnimatingItems_ASM, mPushMatrix, mTranslateAbsXYZ, KillItem, mRotYXZ, phd_right
SetInventoryLighting:
move t9, ra
move t5, a0
move t6, a1
move t7, a2
move t8, a3
cfc2 t0, r0
cfc2 t1, r1
cfc2 t2, r2
cfc2 t3, r3
cfc2 t4, r4
addiu a0, gp, CamGTE-GP_ADDR(gp)
lw at, 0(a0)
lw v0, 4(a0)
lw v1, 8(a0)
lw a1, 0xC(a0)
lw a0, 0x10(a0)
ctc2 at, r0
ctc2 v0, r1
ctc2 v1, r2
ctc2 a1, r3
ctc2 a0, r4
li v0, 0xF000F000
li v1, 0x1000
jal DEL_ApplyMatrixSV
addiu a0, gp, LightPos+0x0-GP_ADDR(gp)
li v0, 0xF0001000
li v1, 0xFFFFF000
jal DEL_ApplyMatrixSV
addiu a0, gp, LightPos+0x6-GP_ADDR(gp)
lui v0, 0x1000
li v1, 0xFFFFF000
jal DEL_ApplyMatrixSV
addiu a0, gp, LightPos+0xC-GP_ADDR(gp)
ctc2 t0, r0
ctc2 t1, r1
ctc2 t2, r2
ctc2 t3, r3
ctc2 t4, r4
andi v0, t5, 0xFF
sll v0, 4
andi v1, t6, 0xFF
sll v1, 20
or v0, v1
ctc2 v0, r16
andi v0, t7, 0xFF
sll v0, 4
andi v1, t5, 0xFF00
sll v1, 12
or v0, v1
ctc2 v0, r17
sra v0, t6, 4
andi v0, 0xFF0
andi v1, t7, 0xFF00
sll v1, 12
or v0, v1
ctc2 v0, r18
sra v0, t5, 12
andi v0, 0xFF0
sra v1, t6, 12
andi v1, 0xFF0
sll v1, 16
or v0, v1
ctc2 v0, r19
sra v0, t7, 12
andi v0, 0xFF0
ctc2 v0, r20
andi a0, t8, 0xFF
sll a0, 4
sra a1, t8, 4
andi a1, 0xFF0
sra a2, t8, 12
andi a2, 0xFF0
ctc2 a0, r13
ctc2 a1, r14
ctc2 a2, r15
li v0, 0x808080
mtc2 v0, r6
ctc2 zero, r28
jr t9
nop
DEL_ApplyMatrixSV:
mtc2 v0, r0
mtc2 v1, r1
nop
nop
cop2 0x486012
mfc2 at, r9
mfc2 v0, r10
mfc2 v1, r11
sh at, 0(a0)
sh v0, 2(a0)
jr ra
sh v1, 4(a0)
TriggerDynamic:
bltz a0, locret_8FF68
lui t3, 0xA
bltz a3, locret_8FF68
la t3, dynamics;fixme can't do this in delay slot
beqz a3, locret_8FF68
lw v1, number_dynamics-GP_ADDR(gp)
li v0, 0x20
bne v1, v0, loc_8FECC
move t0, t3
move t1, zero
move t2, zero
loc_8FE50:
lw at, 0(t3)
lw v0, camera+0x0-GP_ADDR(gp)
lw v1, 4(t3)
subu at, v0, at
lw v0, camera+0x4-GP_ADDR(gp)
mtc2 at, r9
subu v0, v1
lw at, 8(t3)
lw v1, camera+0x8-GP_ADDR(gp)
mtc2 v0, r10
subu v1, at
mtc2 v1, r11
nop
nop
cop2 0xA00428
mfc2 at, r25
mfc2 v0, r26
mfc2 v1, r27
addu at, v0
addu v1, at, v1
slt at, t1, v1
beqz at, loc_8FEB0
addiu t2, 1
move t1, v1
move t0, t3
loc_8FEB0:
slti v0, t2, 0x20
bnez v0, loc_8FE50
addiu t3, 0x18
lw v1, number_dynamics-GP_ADDR(gp)
move t3, t0
j loc_8FEDC
addiu v1, -1
loc_8FECC:
sll at, v1, 1
addu at, v1
sll at, 3
addu t3, at
loc_8FEDC:
sll v0, a3, 8
lui at, 0x20
div at, v0
lw t0, 0x10(sp)
lw t1, 0x14(sp)
lw t2, 0x18(sp)
sh v0, 0x10(t3)
li at, 1
sb at, 0xC(t3)
sw a0, 0(t3)
sw a1, 4(t3)
sw a2, 8(t3)
addiu v1, 1
sw v1, number_dynamics-GP_ADDR(gp)
sb t0, 0xD(t3)
sb t1, 0xE(t3)
sb t2, 0xF(t3)
slti at, a3, 8
mflo v0
beqz at, locret_8FF68
sw v0, 0x14(t3)
mult t0, a3
mflo t0
sra t0, 3
nop
mult t1, a3
sb t0, 0xD(t3)
mflo t1
sra t1, 3
nop
mult t2, a3
sb t1, 0xE(t3)
mflo t2
sra t2, 3
sb t2, 0xF(t3)
locret_8FF68:
jr ra
nop
DrawMonoScreen:
lui v0, 0x6400
or t6, a0, v0
move t4, zero
li t2, 0x400040
lw a2, db+0x4-GP_ADDR(gp)
lw a0, db+0x8-GP_ADDR(gp)
lhu t7, ClutStartY-GP_ADDR(gp)
lw t5, 0x1F40(a2)
sll t7, 6
ori t7, 0x3C
li a3, 0xE1000610
lui t0, 0x600
move t1, zero
loc_8F17C:
sll t3, t4, 6
loc_8F180:
sll a1, t1, 6
sll v0, t3, 16
or v0, a1
sw zero, 8(a0)
sw t6, 0xC(a0)
sw v0, 0x10(a0)
sw t2, 0x18(a0)
srl v0, a1, 8
addiu v0, 0xD
or v0, a3
andi a1, 0xFF
andi at, t3, 0xFF
sll at, 8
or at, a1
or t5, t0
sw t5, 0(a0)
sw v0, 4(a0)
sh at, 0x14(a0)
sh t7, 0x16(a0)
move t5, a0
addiu t1, 1
slti v0, t1, 8
bnez v0, loc_8F180
addiu a0, 0x1C
addiu t4, 1
slti v0, t4, 4
bnez v0, loc_8F17C
move t1, zero
sw t5, 0x1F40(a2)
jr ra
sw a0, db+0x8-GP_ADDR(gp)
PrintAllOtherObjects_ASM:
move fp, ra
lw s5, room-GP_ADDR(gp)
sll v1, s3, 2
addu v1, s3
sll v1, 4
addu s5, v1
jal mPushMatrix
sb zero, 0x37(s5)
lw a0, 0x14(s5)
lw a1, 0x18(s5)
jal mTranslateAbsXYZ
lw a2, 0x1C(s5)
lh s4, 0x48(s5)
li v0, 0x200
sw v0, phd_right-GP_ADDR(gp)
li v0, 0xF0
sw v0, phd_bottom-GP_ADDR(gp)
li v0, 0xFFFFFFFF
sw zero, phd_left-GP_ADDR(gp)
sw zero, phd_top-GP_ADDR(gp)
beq s4, v0, loc_8F5FC
sll v0, s4, 3
loc_8F558:
addu v0, s4
sll v0, 4
addu s3, s7, v0
lw v0, 0x84(s3)
lh at, 0xC(s3)
la s6, objects
sll at, 6
li v1, 6
andi v0, 6
beq v0, v1, loc_8F5AC
addu s6, at
lhu v0, 0x32(s6)
lw v1, 0x1C(s6)
andi v0, 0x200
bnez v0, loc_8F5AC
nop
beqz v1, loc_8F5AC
nop
jalr v1
move a0, s3
loc_8F5AC:
lw v1, 0x34(s6)
nop
beqz v1, loc_8F5C4
nop
jalr v1
move a0, s3
loc_8F5C4:
lhu v1, 0x30(s3)
li at, 0x80
addiu v0, v1, -1
sltiu v0, v0, 0x7F
beqz v0, loc_8F5EC
addiu v1, 1
bne v1, at, loc_8F5EC
sh v1, 0x30(s3)
jal KillItem
move a0, s4
loc_8F5EC:
lh s4, 0x1A(s3)
li v0, 0xFFFFFFFF
bne s4, v0, loc_8F558
sll v0, s4, 3
loc_8F5FC:
lh a0, 0x4A(s5)
li v0, 0xFFFFFFFF
beq a0, v0, loc_8F6EC
loc_8F608:
sll v0, a0, 1
addu v0, a0
sll v0, 2
subu v0, a0
lw a0, effects-GP_ADDR(gp)
sll v0, 2
addu s4, a0, v0
lh v1, 0x16(s4)
la s3, objects
sll v1, 6
addu s3, v1
lw a0, 0x1C(s3)
lh v0, 0x32(s3)
beqz a0, loc_8F6E0
andi v0, 1
beqz v0, loc_8F6E0
nop
jal mPushMatrix
nop
lw a0, 0(s4)
lw a1, 4(s4)
jal mTranslateAbsXYZ
lw a2, 8(s4)
addiu t2, -0x15
sltiu t2, t2, 0x4FEB
beqz t2, loc_8F6D8
nop
lh a0, 0xE(s4)
lh a1, 0xC(s4)
jal mRotYXZ
lh a2, 0x10(s4)
lh a3, 0x14(s4)
lw a0, 0(s4)
lw a1, 4(s4)
lw a2, 8(s4)
la v0, duff_item+0x54
sw v0, 0x10(sp)
jal S_CalculateLight
sb zero, 0x2F(v0)
lh at, 0(s3)
lh v0, 0x20(s4)
beqz at, loc_8F6C0
nop
lh v0, 2(s3)
loc_8F6C0:
lw v1, meshes-GP_ADDR(gp)
sll v0, 2
addu v0, v1
lw a0, 0(v0)
jal phd_PutPolygons
li a1, 0xFFFFFFFF
loc_8F6D8:
jal mPopMatrix
nop
loc_8F6E0:
lh a0, 0x18(s4)
li at, 0xFFFFFFFF
bne a0, at, loc_8F608
loc_8F6EC:
li v0, 0x1FF
jal mPopMatrix
sw v0, 0x38(s5)
li v0, 0xEF
jr fp
sw v0, 0x3C(s5)
print_all_object_NOW:
addiu sp, -0x48
sw s0, 0x48-0x28(sp)
sw s1, 0x48-0x24(sp)
sw s2, 0x48-0x20(sp)
sw s3, 0x48-0x1C(sp)
sw s4, 0x48-0x18(sp)
sw s5, 0x48-0x14(sp)
sw s6, 0x48-0x10(sp)
sw s7, 0x48-0xC(sp)
sw ra, 0x48-0x4(sp)
jal CalcAllAnimatingItems_ASM
sw fp, 0x48-0x8(sp)
lw s7, items-GP_ADDR(gp)
lw s0, number_draw_rooms-GP_ADDR(gp)
la s1, draw_rooms
blez s0, loc_8F4D0
nop
loc_8F4BC:
lh s3, 0(s1)
jal PrintAllOtherObjects_ASM
addiu s0, -1
bnez s0, loc_8F4BC
addiu s1, 2
loc_8F4D0:
lw ra, 0x48-0x4(sp)
lw fp, 0x48-0x8(sp)
lw s7, 0x48-0xC(sp)
lw s6, 0x48-0x10(sp)
lw s5, 0x48-0x14(sp)
lw s4, 0x48-0x18(sp)
lw s3, 0x48-0x1C(sp)
lw s2, 0x48-0x20(sp)
lw s1, 0x48-0x24(sp)
lw s0, 0x48-0x28(sp)
jr ra
addiu sp, 0x48
CalcClipWindow_ONGTE:
andi t2, a1, 0xFFFF
andi t5, a0, 0xFFFF
lw t7, lara_item-GP_ADDR(gp)
lw t4, number_draw_rooms-GP_ADDR(gp)
lw t6, room-GP_ADDR(gp)
lw t7, 0x18(t7)
li a0, 0x200
move a1, zero
li a2, 0x100
move a3, zero
blez t4, locret_8F46C
move t3, zero
la t1, draw_rooms
loc_8F3AC:
lh t0, 0(t1)
addiu t3, 1
sll v1, t0, 2
addu v1, t0
sll v1, 4
beqz t2, loc_8F3DC
addu v1, t6, v1
lhu at, 0x4E(v1)
nop
andi at, 0x28
beqz at, loc_8F440
nop
loc_8F3DC:
bne t0, t5, loc_8F3EC
nop
beqz t2, loc_8F440
nop
loc_8F3EC:
bne t0, t7, loc_8F3FC
nop
beqz t2, loc_8F440
nop
loc_8F3FC:
lh t0, 0x38(v1)
lh v0, 0x3A(v1)
slt at, t0, a0
beqz at, loc_8F414
slt at, a1, v0
addiu a0, t0, 1
loc_8F414:
beqz at, loc_8F420
lh t0, 0x3C(v1)
addiu a1, v0, -1
loc_8F420:
lh v0, 0x3E(v1)
slt at, t0, a2
beqz at, loc_8F434
slt at, a3, v0
addiu a2, t0, 1
loc_8F434:
beqz at, loc_8F440
nop
addiu a3, v0, -1
loc_8F440:
slt at, t3, t4
bnez at, loc_8F3AC
addiu t1, 2
loc_8F44C:
sll a0, 16
sll a1, 16
sll a2, 16
sll a3, 16
mtc2 a0, r6
mtc2 a1, r20
mtc2 a2, r21
mtc2 a3, r22
locret_8F46C:
jr ra
nop
DrawFlash:
lh a0, FlashFadeR-GP_ADDR(gp)
lh v1, FlashFader-GP_ADDR(gp)
lui a1, 0xF0
mult a0, v1
lh v0, FlashFadeG-GP_ADDR(gp)
lh a2, FlashFadeB-GP_ADDR(gp)
mflo a0
li a1, 0xF00200
li a3, 1
mult v0, v1
sw zero, 0x10(sp)
mflo v0
sra a0, 5
sll v0, 3
mult a2, v1
andi v0, 0xFF00
andi a0, 0xFF
mflo a2
sra a2, 5
andi a2, 0xFF
sll a2, 16
or a2, v0
or a2, a0
lui v0, 0x6200
move a0, zero
j DrawPsxTile
or a2, v0
DrawPsxTile:
lw t0, db+0x8-GP_ADDR(gp)
lw v0, db+0x10-GP_ADDR(gp)
lw t1, 0x10(sp)
sltu v0, t0, v0
beqz v0, locret_8F7D0
lui v0, 0xE100
lw v1, db+0x4-GP_ADDR(gp)
li v0, 0xE1000200
sw zero, 8(t0)
sw a2, 0xC(t0)
sw a0, 0x10(t0)
sw a1, 0x14(t0)
andi a3, 3
sll a3, 5
or v0, a3
sll t1, 2
addu v1, t1
lw a0, 0(v1)
lui at, 0x500
or a0, at
sw t0, 0(v1)
sw a0, 0(t0)
sw v0, 4(t0)
addiu t0, 0x18
locret_8F7D0:
jr ra
sw t0, db+0x8-GP_ADDR(gp)
insert_psx_clip_window:
sw a3, 0x10(sp)
move a3, a2
move a2, a1
lw v0, db-GP_ADDR(gp)
move a1, a0
lui a0, 0x1F80
beqz v0, loc_8FDCC
sw ra, 0x60(a0)
lui v0, 0xF0
addiu a2, 0xF0
loc_8FDCC:
jal SetDefDrawEnv
sw v0, 0x64(a0)
lui a1, 0x1F80
lw v0, 0x64(a1)
lw a0, db+0x8-GP_ADDR(gp)
sw v0, 0x8(a1)
li v0, 1
sb v0, 0x16(a1)
jal SetDrawEnv
sb zero, 0x18(a1)
lw ra, 0x1F800060
lw a0, db+0x4-GP_ADDR(gp)
lw a1, db+0x8-GP_ADDR(gp)
lw at, 0x280C(a0)
lui v0, 0x600
or at, v0
sw a1, 0x280C(a0)
sw at, 0(a1)
addiu a1, 0x1C
jr ra
sw a1, db+0x8-GP_ADDR(gp)