forked from zeldaret/oot-vc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathframe.c
More file actions
4554 lines (3989 loc) · 151 KB
/
frame.c
File metadata and controls
4554 lines (3989 loc) · 151 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
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
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include "emulator/frame.h"
#include "emulator/cpu.h"
#include "emulator/helpRVL.h"
#include "emulator/ram.h"
#include "emulator/rdp.h"
#include "emulator/rsp.h"
#include "emulator/system.h"
#include "emulator/vc64_RVL.h"
#include "emulator/xlCoreRVL.h"
#include "emulator/xlFileRVL.h"
#include "emulator/xlHeap.h"
#include "emulator/xlObject.h"
#include "emulator/xlPostRVL.h"
#include "emulator/xlText.h"
#include "macros.h"
#include "math.h"
#include "mem_funcs.h"
#include "revolution/demo.h"
#include "revolution/gx.h"
#include "revolution/mtx.h"
#include "revolution/vi.h"
void CopyAndConvertCFB(u16* srcP);
static bool frameDrawTriangle_C0T0(Frame* pFrame, Primitive* pPrimitive);
static bool frameDrawTriangle_C1T0(Frame* pFrame, Primitive* pPrimitive);
static bool frameDrawTriangle_C3T0(Frame* pFrame, Primitive* pPrimitive);
static bool frameDrawTriangle_C0T3(Frame* pFrame, Primitive* pPrimitive);
static bool frameDrawTriangle_C1T3(Frame* pFrame, Primitive* pPrimitive);
static bool frameDrawTriangle_C3T3(Frame* pFrame, Primitive* pPrimitive);
static bool frameDrawLine_C0T0(Frame* pFrame, Primitive* pPrimitive);
static bool frameDrawLine_C1T0(Frame* pFrame, Primitive* pPrimitive);
static bool frameDrawLine_C2T0(Frame* pFrame, Primitive* pPrimitive);
static bool frameDrawLine_C0T2(Frame* pFrame, Primitive* pPrimitive);
static bool frameDrawLine_C1T2(Frame* pFrame, Primitive* pPrimitive);
static bool frameDrawLine_C2T2(Frame* pFrame, Primitive* pPrimitive);
static bool frameDrawSetupSP(Frame* pFrame, s32* pnColors, bool* pbFlag, s32 nVertexCount);
static bool frameDrawSetupDP(Frame* pFrame, s32* pnColors, bool* pbFlag, s32 nVertexCount);
static bool frameDrawRectFill(Frame* pFrame, Rectangle* pRectangle);
static bool frameDrawTriangle_Setup(Frame* pFrame, Primitive* pPrimitive);
static bool frameDrawRectTexture_Setup(Frame* pFrame, Rectangle* pRectangle);
static inline void CopyCFB(u16* srcP);
static bool packTakeBlocks(s32* piPack, u32* anPack, s32 nPackCount, s32 nBlockCount);
static inline bool packFreeBlocks(s32* piPack, u32* anPack, s32 nPackCount);
static inline bool frameTransposeMatrix(Mtx44 matrixTarget, Mtx44 matrixSource);
static bool frameLoadTile(Frame* pFrame, FrameTexture** ppTexture, s32 iTileCode);
static bool frameUpdateCache(Frame* pFrame);
static inline bool frameGetMatrixHint(Frame* pFrame, u32 nAddress, s32* piHint);
static bool frameResetCache(void);
static bool frameSetupCache(void);
_XL_OBJECTTYPE gClassFrame = {
"Frame",
sizeof(Frame),
NULL,
(EventFunc)frameEvent,
};
// .sdata
static char lbl_8025C820[] = ".";
static u8 sRemapI[] = {0, 2, 4, 6, 8, 10, 12, 15};
static char lbl_8025C830[] = ".T64";
// .data
u32 ganNameTexMtx[] = {
0x1E, 0x21, 0x24, 0x27, 0x2A, 0x2D, 0x30, 0x33,
};
GXTexCoordID ganNameTexCoord[] = {
GX_TEXCOORD0, GX_TEXCOORD1, GX_TEXCOORD2, GX_TEXCOORD3, GX_TEXCOORD4, GX_TEXCOORD5, GX_TEXCOORD6, GX_TEXCOORD7,
};
s32 lbl_80172710[] = {
0x000000BE,
0x000000BE,
0x000000BE,
};
s32 sCommandCodes_1679[] = {
0xF5500000, 0x07080200, 0xE6000000, 0x00000000, 0xF3000000, 0x073BF01A, 0xE7000000, 0x00000000,
};
s32 sCommandCodes_1702[] = {
0xE7000000, 0x00000000, 0xEF000CF0, 0x0F0A4004, 0xFB000000,
0xFFFFFFFF, 0xFC12FE25, 0xFFFFFBFD, 0xFF10013F, 0x00000000,
};
s32 sCommandCodes2[] = {
0xE7000000, 0x00000000, 0xEF000CF0, 0x0F0A4004, 0xFB000000,
0xFFFFFFFF, 0xFC12FE25, 0xFFFFFBFD, 0xFF10013F, 0x00000000,
};
s32 GBIcode[] = {
0xED000000,
0x0B000000,
0x0A000000,
};
u32 sZBufShift[8][2] = {
{0x0003F800, 0}, {0x0003F000, 0}, {0x0003E000, 1}, {0x0003C000, 2},
{0x00038000, 3}, {0x00030000, 4}, {0x00020000, 5}, {0x00000000, 6},
};
u32 ganNameColor[] = {
0, 1, 2, 3, 4, 5, 6, 7,
};
GXTexMapID ganNamePixel[] = {
GX_TEXMAP0, GX_TEXMAP1, GX_TEXMAP2, GX_TEXMAP3, GX_TEXMAP4, GX_TEXMAP5, GX_TEXMAP6, GX_TEXMAP7,
};
FrameDrawFunc gapfDrawTriangle[8] = {
(FrameDrawFunc)frameDrawTriangle_C0T0,
(FrameDrawFunc)frameDrawTriangle_C1T0,
NULL,
(FrameDrawFunc)frameDrawTriangle_C3T0,
(FrameDrawFunc)frameDrawTriangle_C0T3,
(FrameDrawFunc)frameDrawTriangle_C1T3,
NULL,
(FrameDrawFunc)frameDrawTriangle_C3T3,
};
FrameDrawFunc gapfDrawLine[6] = {
(FrameDrawFunc)frameDrawLine_C0T0, (FrameDrawFunc)frameDrawLine_C1T0, (FrameDrawFunc)frameDrawLine_C2T0,
(FrameDrawFunc)frameDrawLine_C0T2, (FrameDrawFunc)frameDrawLine_C1T2, (FrameDrawFunc)frameDrawLine_C2T2,
};
char lbl_80172948[] = "Waiting for valid?\n";
s32 anRenderModeDatabaseCycle2[] = {
0x0C192078, 0x00552078, 0x0C184F50, 0x00504A50, 0x0F0A4000, 0xC8112078, 0x0C187858, 0x00442078, 0x00553078,
0xC8113078, 0x00443078, 0x00552D58, 0xC8112D58, 0x005049D8, 0xC81049D8, 0x0C193078, 0x00504240, 0x5F505240,
0x0C184240, 0x0C182048, 0x0C183048, 0x0C182078, 0x0C192D58, 0x0C1849D8, 0x0F0A7008, 0x0C1841C8, 0x0C184DD8,
0x0C183078, 0x0C1845D8, 0x00504241, 0x0C184341, 0x0C184241, 0xC8104DD8, 0xC8104F50, 0x00504341, 0xC8104A50,
0x00504340, 0x0C184340, 0xC8104B50, 0x0C184B50, 0x0C184B51, 0x00504B51, 0x0F0A4004, 0x0F0A3231, 0x00504B50,
0xC81049F8, 0xC8103478, 0x005041C8, 0xC4104240, 0x00552038, 0x0F0A100C, 0x0C184A50, 0xC8104A51, 0xC8112479,
0xC81045D8, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000,
};
s32 anRenderModeDatabaseCopy[] = {
0x0F0A7008, 0x00000001, 0x0F0A4001, 0x00442478, 0x00442479, 0x005041C9, 0x00552079, 0x00552078, 0x005045D8,
0x005045D9, 0x00504DD8, 0x00504DD9, 0x00553078, 0x00553079, 0x0F0A4000, 0x005049D8, 0x005049D9, 0x00442078,
0x00442079, 0x0F0A7009, 0x00504240, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000,
};
s32 anRenderModeDatabaseFill[] = {
0x0F0A4000, 0x0C084000, 0x00000001, 0x0F0A4001, 0x00504240, 0xC8112078, 0x00504341, 0x00504244, 0x00504340,
0x00504241, 0x00504B50, 0x0C184241, 0x0F0A4004, 0x00553049, 0x00552078, 0x0F0A100C, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000,
};
s32 anRenderModeDatabaseCycle1[] = {
0x0F0A4000, 0x00552048, 0x0F0A7008, 0x00552078, 0x0C084000, 0x00504241, 0x00504240, 0x0F0A4001, 0x005041C8,
0x00552D58, 0x0C184F50, 0x00504F50, 0x0C192078, 0x00504A50, 0x00000001, 0x005049D8, 0xC8112078, 0x0C187858,
0x00552230, 0x00442478, 0x00443078, 0x00442479, 0x00443079, 0x005041C9, 0x00553048, 0x00553078, 0x00504DD8,
0x005045D8, 0x004049F8, 0x004049D8, 0x00442078, 0xC8113078, 0x005049DB, 0x00442D58, 0xC8112D58, 0x004049F8,
0xC81049D8, 0x0C193078, 0x00504B50, 0x00504340, 0x5F505240, 0x0C182078, 0x0C182048, 0x0F0A7009, 0x0C1841C8,
0x0C184240, 0x0C1849D8, 0x00504244, 0x0C184340, 0x00504B51, 0x0C184B50, 0x0F0A4004, 0x0F0A4044, 0x0F0A0004,
0xC8104B50, 0x0FA54044, 0x00504341, 0x00553049, 0x0F0A3231, 0xC8104F50, 0x00552038, 0xC4104240, 0x00504344,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000,
};
// .sbss
static bool gbFrameValid;
static bool gbFrameBegin;
static volatile bool sCopyFrameSyncReceived;
static u32 snScissorXOrig;
static u32 snScissorYOrig;
static u32 snScissorWidth;
static u32 snScissorHeight;
bool lbl_8025D098;
s32 nCopyFrame;
s32 gnCountMapHack;
static u32 sDestinationBuffer;
static u32 sSrcBuffer;
s32 nLastFrame;
static u32 sNumAddr;
bool bSkip;
s32 nCounter;
static u8 sSpecialZeldaHackON;
static u32 gHackCreditsColor;
bool gNoSwapBuffer;
static bool snScissorChanged;
// TODO: identify this
static s32 lbl_8025D07C;
static s32 lbl_8025D168;
// .bss
static u32 sConstantBufAddr[6] ATTRIBUTE_ALIGN(32);
static u16 sTempZBuf[N64_FRAME_WIDTH * N64_FRAME_HEIGHT / 16][4][4] ATTRIBUTE_ALIGN(32);
static GXTexObj sFrameObj1;
static GXTexObj sFrameObj2;
static GXTexObj sFrameObj_1564;
static GXTexObj sFrameObj_1565;
static GXTexObj sFrameObj_1568;
static u32 line_1582[N64_FRAME_WIDTH / 4][4][4];
static u16 line_1606[N64_FRAME_WIDTH / 4][4][4];
static u16 line_1630[N64_FRAME_WIDTH / 4][4][4];
static GXTexObj sFrameObj_1647;
static GXTexObj sFrameObj_1660;
static GXTexObj lbl_801A1680;
static GXTexObj frameObj_1663;
static GXTexObj frameObj_1673;
static u16 tempLine[ZELDA_PAUSE_EQUIP_PLAYER_WIDTH / 4][4][4];
Mtx gTextureMatrix[8];
FrameTexture* gpTexture[8];
// .sdata2
const f32 D_80135E00 = 0.0f;
const f32 D_80135E04 = 0.25f;
const f32 D_80135E08 = 2.0f;
const f64 D_80135E10 = 4503601774854144.0;
const f32 D_80135E18 = 0.0625f;
const f32 D_80135E1C = 0.0078125f;
const f32 D_80135E20 = 4096.0f;
const f32 D_80135E24 = 4194304.0f;
const f64 D_80135E28 = 4503599627370496.0;
const f32 D_80135E30 = 0.5f;
const f32 D_80135E34 = 3.0f;
const f32 D_80135E38 = 1.0f;
const f64 D_80135E40 = 0.5;
const f64 D_80135E48 = 3.0;
const f32 D_80135E50 = 0.2267303466796875f;
const f32 D_80135E54 = 0.3183135986328125f;
const f32 D_80135E58 = 0.00624f;
const f32 D_80135E5C = 0.006242f;
const f32 D_80135E60 = 640.0f;
const f32 D_80135E64 = 480.0f;
const f32 D_80135E68 = 320.0f;
const f32 D_80135E6C = 240.0f;
const f64 D_80135E70 = 262143.0;
const f64 D_80135E78 = 43.52;
const f32 D_80135E80 = 80.0f;
const f32 D_80135E84 = 31.0f;
const f32 D_80135E88 = 0.015625f;
const f32 D_80135E8C = 143.0f;
const f32 D_80135E90 = 0.859375f;
const f32 D_80135E94 = 0.95f;
const f32 D_80135E98 = 0.9f;
const f32 D_80135E9C = 0.85f;
const f32 D_80135EA0 = 0.8f;
const f32 D_80135EA4 = -1.0;
const f32 D_80135EA8 = 319.0f;
const f32 D_80135EAC = 239.0f;
const f32 D_80135EB0 = -1001.0;
const f32 D_80135EB4 = -53.0;
const f32 D_80135EB8 = -3080.0;
const f32 D_80135EBC = 6067.0f;
const f32 D_80135EC0 = -31.0;
const f32 D_80135EC4 = 1669.0f;
const f32 D_80135EC8 = 1000.0f;
const f32 D_80135ECC = 32000.0f;
const f32 D_80135ED0 = 30.0f;
const f32 D_80135ED4 = 1.3333334f;
const f32 D_80135ED8 = 0.1f;
const f32 D_80135EDC = 0.0015f;
const f32 D_80135EE0 = 65536.0f;
const f32 D_80135EE4 = 1001.0f;
const f32 D_80135EE8 = 500.0f;
const f32 D_80135EEC = 970.0f;
const f32 D_80135EF0 = 59.0f;
const f32 D_80135EF4 = 990.0f;
const f32 D_80135EF8 = 0.21f;
const f32 D_80135EFC = 0.35f;
const f32 D_80135F00 = 12800.0f;
const f32 D_80135F04 = 0.6f;
const f32 D_80135F08 = 0.7f;
const f32 D_80135F0C = 44.0f;
const f32 D_80135F10 = 0.13f;
const f32 D_80135F14 = 45.0f;
const f32 D_80135F18 = 15.0f;
const f32 D_80135F1C = 0.38f;
const f32 D_80135F20 = 900.0f;
const f32 D_80135F24 = 350.0f;
const f32 D_80135F28 = 10.0f;
const f32 D_80135F2C = 200.0f;
const f32 D_80135F30 = 128000.0f;
const f32 D_80135F34 = -25344.0;
const f32 D_80135F38 = 25600.0f;
const f32 D_80135F3C = 2200.0f;
const f32 D_80135F40 = 0.575f;
const f32 D_80135F44 = 0.75f;
const f32 D_80135F48 = -21077.0;
const f32 D_80135F4C = 21333.0f;
const f32 D_80135F50 = -90.0;
const f32 D_80135F54 = 258.0f;
const f32 D_80135F58 = 0.45f;
const f32 D_80135F5C = -667.0;
const f32 D_80135F60 = 688.0f;
const f32 D_80135F64 = 0.00390625f;
const f32 D_80135F68 = 860.0f;
const f32 D_80135F6C = 0.15f;
const f32 D_80135F70 = 140.0f;
const f32 D_80135F74 = 0.28f;
const f32 D_80135F78 = 0.72f;
const f32 D_80135F7C = 0.26f;
const f32 D_80135F80 = 8.44f;
const f64 D_80135F88 = 8.44;
static inline bool frameSetProjection(Frame* pFrame, s32 iHint) {
MatrixHint* pHint = &pFrame->aMatrixHint[iHint];
pFrame->nMode |= 0x24000000;
pFrame->nMode &= ~0x18000000;
if (pHint->eProjection == FMP_PERSPECTIVE) {
C_MTXPerspective(pFrame->matrixProjection, pHint->rFieldOfViewY, pHint->rAspect, pHint->rClipNear,
pHint->rClipFar);
} else if (pHint->eProjection == FMP_ORTHOGRAPHIC) {
C_MTXOrtho(pFrame->matrixProjection, 0.0f, pFrame->anSizeY[FS_SOURCE] - 1.0f, 0.0f,
pFrame->anSizeX[FS_SOURCE] - 1.0f, pHint->rClipNear, pHint->rClipFar);
} else {
return false;
}
pFrame->eTypeProjection = pHint->eProjection;
return true;
}
static inline bool frameGetMatrixHint(Frame* pFrame, u32 nAddress, s32* piHint) {
s32 iHint;
for (iHint = 0; iHint < pFrame->iHintMatrix; iHint++) {
if (pFrame->aMatrixHint[iHint].nAddressFixed == nAddress && pFrame->aMatrixHint[iHint].nCount >= 0) {
pFrame->aMatrixHint[iHint].nCount = 4;
*piHint = iHint;
return true;
}
}
return false;
}
static bool frameConvertYUVtoRGB(u32* YUV, u32* RGB) {
s32 Yl;
s32 R;
s32 G;
s32 B;
Yl = YUV[0] - 16;
B = (s32)((YUV[1] - 128) * 20830 + Yl * 12014) >> 16;
G = (s32)(Yl * 11079 + ((YUV[2] - 128) * -6480 - B * 12729)) >> 16;
R = (s32)(Yl * 31026 - B * 24987 - G * 128660) >> 16;
if (R > 31) {
R = 31;
} else if (R < 0) {
R = 0;
}
if (G > 31) {
G = 31;
} else if (G < 0) {
G = 0;
}
if (B > 31) {
B = 31;
} else if (B < 0) {
B = 0;
}
RGB[0] = R;
RGB[1] = G;
RGB[2] = B;
return true;
}
static bool packTakeBlocks(s32* piPack, u32* anPack, s32 nPackCount, s32 nBlockCount) {
s32 nOffset;
s32 nCount;
s32 iPack;
u32 nPack;
u32 nMask;
u32 nMask0;
if (nBlockCount >= 32 || nBlockCount < 0) {
return false;
}
nMask0 = (1 << nBlockCount) - 1;
nCount = 33 - nBlockCount;
for (iPack = 0; iPack < nPackCount; iPack++) {
nPack = anPack[iPack];
if (nPack != -1) {
nMask = nMask0;
nOffset = nCount;
do {
if ((nPack & nMask) == 0) {
anPack[iPack] |= nMask;
*piPack = (nBlockCount << 16) | ((iPack << 5) + (nCount - nOffset));
return true;
}
nMask <<= 1;
nOffset--;
} while (nOffset != 0);
}
}
*piPack = -1;
return false;
}
static bool packFreeBlocks(s32* piPack, u32* anPack, s32 nPackCount) {
s32 iPack;
u32 nMask;
if (*piPack == -1) {
return true;
}
nMask = ((1 << (*piPack >> 16)) - 1) << (*piPack & 0x1F);
iPack = (*piPack & 0xFFFF) >> 5;
if ((anPack[iPack] & nMask) == nMask) {
anPack[iPack] &= ~nMask;
*piPack = -1;
return true;
}
return false;
}
static bool frameMakeTexture(Frame* pFrame, FrameTexture** ppTexture) {
u32 nMask;
s32 iTexture;
s32 iTextureUsed;
iTextureUsed = 0;
while (iTextureUsed < ARRAY_COUNTU(pFrame->anTextureUsed) && (nMask = pFrame->anTextureUsed[iTextureUsed]) == -1) {
iTextureUsed++;
}
if (iTextureUsed == ARRAY_COUNTU(pFrame->anTextureUsed)) {
return false;
}
iTexture = 0;
while (nMask & 1) {
iTexture++;
nMask >>= 1;
}
pFrame->anTextureUsed[iTextureUsed] |= (1 << iTexture);
iTexture = (iTextureUsed << 5) + iTexture;
*ppTexture = &pFrame->aTexture[iTexture];
(*ppTexture)->iPackPixel = -1;
(*ppTexture)->iPackColor = -1;
(*ppTexture)->pTextureNext = NULL;
if (++pFrame->nBlocksTexture > pFrame->nBlocksMaxTexture) {
pFrame->nBlocksMaxTexture = pFrame->nBlocksTexture;
}
return true;
}
static inline bool frameFreeTLUT(Frame* pFrame, FrameTexture* pTexture) {
if (!packFreeBlocks(&pTexture->iPackColor, pFrame->anPackColor, ARRAY_COUNT(pFrame->anPackColor))) {
return false;
}
return true;
}
static inline bool frameFreePixels(Frame* pFrame, FrameTexture* pTexture) {
if (!frameFreeTLUT(pFrame, pTexture)) {
return false;
}
if (!packFreeBlocks(&pTexture->iPackPixel, pFrame->anPackPixel, ARRAY_COUNT(pFrame->anPackPixel))) {
return false;
}
return true;
}
static inline bool frameFreeTexture(Frame* pFrame, FrameTexture* pTexture) {
s32 iTexture = (u8*)pTexture - (u8*)&pFrame->aTexture[0];
if (!frameFreePixels(pFrame, pTexture)) {
return false;
}
iTexture /= sizeof(FrameTexture);
pFrame->anTextureUsed[iTexture >> 5] &= ~(1 << (iTexture & 0x1F));
pFrame->nBlocksTexture--;
return true;
}
static inline void frameResetCache_UnknownInline(Frame* pFrame) {
s32 iTexture;
for (iTexture = 0; iTexture < ARRAY_COUNT(pFrame->anPackPixel); iTexture++) {
pFrame->anPackPixel[iTexture] = 0;
}
for (iTexture = 0; iTexture < ARRAY_COUNT(pFrame->anPackColor); iTexture++) {
pFrame->anPackColor[iTexture] = 0;
}
}
static bool frameResetCache(void) {
Frame* pFrame = SYSTEM_FRAME(gpSystem);
s32 iTexture;
for (iTexture = 0; iTexture < ARRAY_COUNT(pFrame->apTextureCached); iTexture++) {
pFrame->apTextureCached[iTexture] = 0;
}
for (iTexture = 0; iTexture < ARRAY_COUNTU(pFrame->anTextureUsed); iTexture++) {
pFrame->anTextureUsed[iTexture] = 0;
}
frameResetCache_UnknownInline(pFrame);
xlHeapFill32((void**)&pFrame->aTexture, sizeof(pFrame->aTexture), 0);
(void)0;
(void)0;
return true;
}
static inline bool frameSetupCache_UnknownInline(Frame* pFrame) {
ARCDir arcDir;
ARCEntry arcEntry;
if (contentOpenDirNAND(&gCNTHandle.handleNAND, lbl_8025C820, &arcDir)) {
while (ARCReadDir(&arcDir, &arcEntry)) {
const char* szFileName = arcEntry.name;
s32 nLength = strlen(szFileName);
//! @bug: probably meant to check for ".t64" and ".T64"
if (szFileName[nLength - 4] == '.' && (szFileName[nLength - 3] == 'T' || szFileName[nLength - 3] == 'T') &&
szFileName[nLength - 2] == '6' && szFileName[nLength - 1] == '4') {
if (!frameLoadTexturePack(pFrame, szFileName)) {
return false;
}
}
}
ARCCloseDir(&arcDir);
}
return true;
}
static bool frameSetupCache(void) {
Frame* pFrame = SYSTEM_FRAME(gpSystem);
if (!frameResetCache()) {
return false;
}
pFrame->unk_3E36C = NULL;
if (!frameSetupCache_UnknownInline(pFrame)) {
return false;
}
return true;
}
static bool frameUpdateCache(Frame* pFrame) {
// s32 nCount;
// s32 nCountFree;
u32 nMask;
s32 nFrameCount;
s32 nFrameDelta;
s32 iTexture;
s32 iTextureUsed;
s32 iTextureCached;
FrameTexture* pTexture;
FrameTexture* pTextureCached;
FrameTexture* pTextureLast;
nFrameCount = pFrame->nCountFrames;
for (iTextureUsed = 0; iTextureUsed < ARRAY_COUNTU(pFrame->anTextureUsed); iTextureUsed++) {
if ((nMask = pFrame->anTextureUsed[iTextureUsed]) != 0) {
for (iTexture = 0; nMask != 0; iTexture++, nMask >>= 1) {
if (nMask & 1) {
pTexture = &pFrame->aTexture[(iTextureUsed << 5) + iTexture];
if (!(pTexture->nMode & 4)) {
nFrameDelta = pTexture->nFrameLast - nFrameCount;
if (nFrameDelta < 0) {
nFrameDelta = -nFrameDelta;
}
if (nFrameDelta > 1) {
pTextureLast = NULL;
iTextureCached = pTexture->nAddress >> 11;
pTextureCached = pFrame->apTextureCached[iTextureCached];
while (pTextureCached != NULL && pTextureCached != pTexture) {
pTextureLast = pTextureCached;
pTextureCached = pTextureCached->pTextureNext;
}
if (pTextureLast == NULL) {
pFrame->apTextureCached[iTextureCached] = pTextureCached->pTextureNext;
} else {
pTextureLast->pTextureNext = pTextureCached->pTextureNext;
}
if (!frameFreeTexture(pFrame, pTexture)) {
return false;
}
}
}
}
}
}
}
return true;
}
static bool frameLoadTile(Frame* pFrame, FrameTexture** ppTexture, s32 iTileCode) {
bool bFlag;
Tile* pTile;
FrameTexture* pTexture;
FrameTexture* pTextureLast;
u32 nData0;
u32 nData1;
u32 nData2;
u32 nData3;
s32 iTexture;
s32 nShift;
s32 pad;
pTile = &pFrame->aTile[iTileCode & 0xF];
if (pTile->nX0 == 0 && pTile->nY0 == 0 && pTile->nX1 == 0 && pTile->nY1 == 0) {
bFlag = true;
pTile->nX0 = pFrame->aTile[pFrame->iTileLoad].nX0;
pTile->nY0 = pFrame->aTile[pFrame->iTileLoad].nY0;
pTile->nX1 = pFrame->aTile[pFrame->iTileLoad].nX1;
pTile->nY1 = pFrame->aTile[pFrame->iTileLoad].nY1;
nShift = pFrame->aTile[pFrame->iTileLoad].nSize - pTile->nSize;
if (nShift < 0) {
nShift = -nShift;
pTile->nX0 >>= nShift;
pTile->nX1 >>= nShift;
} else {
pTile->nX0 <<= nShift;
pTile->nX1 <<= nShift;
}
pTile->nModeS = 2;
pTile->nModeT = 2;
} else {
bFlag = false;
}
pTile->nCodePixel = pFrame->nCodePixel;
nData0 = (pTile->nX0 & 0xFFFF) | ((pTile->nX1 & 0xFFFF) << 16);
nData1 = (pTile->nY0 & 0xFFFF) | ((pTile->nY1 & 0xFFFF) << 16);
nData2 = ((pTile->nMaskS & 0xF) << 0) | ((pTile->nMaskT & 0xF) << 4) | ((pTile->nModeS & 7) << 8) |
((pTile->nModeT & 7) << 11) | ((pTile->nShiftS & 0xF) << 14) | ((pTile->nShiftT & 0xF) << 18) |
((pTile->nSize & 7) << 22) | ((pTile->nFormat & 7) << 25) | ((pTile->iTLUT & 0xF) << 28);
nData3 = (pTile->nTMEM & 0xFFFF) | ((pTile->nSizeX & 0xFFFF) << 16);
pTexture = pFrame->unk_3E36C;
while (pTexture != NULL) {
if (pTexture->nData2 == nData2 && pTexture->nData3 == nData3 && pTexture->unk_34 == pFrame->unk_2228 &&
pTexture->nAddress == pFrame->nAddressLoad) {
break;
}
pTexture = pTexture->pTextureNext;
}
if (pTexture == NULL) {
if (pFrame->nAddressLoad == -1) {
iTexture = 0;
} else {
iTexture = pFrame->nAddressLoad >> 11;
}
pTextureLast = pTexture = pFrame->apTextureCached[iTexture];
while (pTexture != NULL) {
if (pTexture->nData2 == nData2 && pTexture->nData3 == nData3 && pTexture->nCodePixel == pTile->nCodePixel &&
pTexture->nAddress == pFrame->nAddressLoad) {
break;
}
pTextureLast = pTexture;
pTexture = pTexture->pTextureNext;
}
}
if (pTexture == NULL) {
if (!frameMakeTexture(pFrame, &pTexture)) {
return false;
}
frameMakePixels(pFrame, pTexture, pTile, false);
pTexture->nData0 = nData0;
pTexture->nData1 = nData1;
pTexture->nData2 = nData2;
pTexture->nData3 = nData3;
if (pFrame->nAddressLoad == -1) {
pTexture->nAddress = 0;
} else {
pTexture->nAddress = pFrame->nAddressLoad;
}
if (pTextureLast == NULL) {
pFrame->apTextureCached[iTexture] = pTexture;
} else {
pTextureLast->pTextureNext = pTexture;
}
} else if (!(pTexture->nMode & 4) && pTexture->iPackColor != -1 &&
pTexture->nCodeColor != pFrame->nTlutCode[pTile->iTLUT]) {
frameMakePixels(pFrame, pTexture, pTile, true);
}
pTexture->nFrameLast = pFrame->nCountFrames;
pTexture->nCodeColor = pFrame->nTlutCode[pTile->iTLUT];
pTexture->nCodePixel = pTile->nCodePixel;
pTexture->unk_34 = pFrame->unk_2228;
if (!frameLoadTexture(pFrame, pTexture, iTileCode, pTile)) {
return false;
}
if (ppTexture != NULL) {
*ppTexture = pTexture;
}
if (bFlag) {
pTile->nX0 = pTile->nY0 = pTile->nX1 = pTile->nY1 = 0;
}
return true;
}
bool fn_8004A020(Frame* pFrame) {
s32 i;
if (lbl_80172710[0] != 0xFF || lbl_80172710[1] != 0xFF || lbl_80172710[2] != 0xFF) {
pFrame->nMode &= ~0x40000000;
frameDrawSetup2D(pFrame);
GXSetNumTevStages(1);
GXSetNumChans(1);
GXSetNumTexGens(0);
GXSetTevColorIn(GX_TEVSTAGE0, GX_CC_ZERO, GX_CC_ZERO, GX_CC_ZERO, GX_CC_C0);
GXSetTevAlphaIn(GX_TEVSTAGE0, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, GX_CA_A0);
GXSetTevColorOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_FALSE, GX_TEVPREV);
GXSetTevAlphaOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_FALSE, GX_TEVPREV);
GXSetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD_NULL, GX_TEXMAP_NULL, GX_COLOR_NULL);
GXClearVtxDesc();
GXSetVtxDesc(GX_VA_POS, GX_DIRECT);
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_TEX_ST, GX_RGBA6, 0U);
GXSetAlphaCompare(GX_ALWAYS, 0, GX_AOP_AND, GX_ALWAYS, 0);
for (i = 0; i < 3; i++) {
if (lbl_80172710[i] > 0xFF) {
lbl_80172710[i] = 0xFF;
}
if (lbl_80172710[i] < 0) {
lbl_80172710[i] = 0;
}
}
if (lbl_80172710[0] != 0xFF || lbl_80172710[1] != 0xFF || lbl_80172710[2] != 0xFF) {
GXColor color;
color.r = lbl_80172710[0];
color.g = lbl_80172710[1];
color.b = lbl_80172710[2];
color.a = 0xFF;
GXSetTevColor(GX_TEVREG0, color);
GXSetBlendMode(GX_BM_BLEND, GX_BL_ZERO, GX_BL_SRCCLR, GX_LO_NOOP);
GXBegin(GX_QUADS, GX_VTXFMT0, 4);
GXPosition3f32(0.0f, 0.0f, 0.0f);
GXPosition3f32(N64_FRAME_WIDTH, 0.0f, 0.0f);
GXPosition3f32(N64_FRAME_WIDTH, N64_FRAME_HEIGHT, 0.0f);
GXPosition3f32(0.0f, N64_FRAME_HEIGHT, 0.0f);
GXEnd();
}
pFrame->nMode = 0;
pFrame->nModeVtx = -1;
frameDrawReset(pFrame, 0x47F2D);
}
return true;
}
static inline void fn_8004A314_inline(Mtx44 mtx, f32 a[4], f32 d) {
f32 length;
a[0] = (d * mtx[0][2]) + mtx[0][3];
a[1] = (d * mtx[1][2]) + mtx[1][3];
a[2] = (d * mtx[2][2]) + mtx[2][3];
a[3] = (d * mtx[3][2]) + mtx[3][3];
length = sqrt(SQ(a[0]) + SQ(a[1]) + SQ(a[2]));
a[0] /= length;
a[1] /= length;
a[2] /= length;
a[3] /= length;
}
void fn_8004A314(Frame* pFrame) {
Mtx44 sp28;
f32 sp18[4];
f32 sp8[4];
f32 temp_f1_2;
f32 temp_f2_4;
f32 temp;
if (pFrame->matrixProjection[0][3] != 0.0f || pFrame->matrixProjection[1][3] != 0.0f ||
pFrame->matrixProjection[2][3] != 0.0f) {
PSMTXTranspose(pFrame->matrixProjection, sp28);
PSMTX44Identity(pFrame->unk_3F190);
PSMTX44Identity(pFrame->unk_3F1D0);
pFrame->unk_3F190[2][0] = -sp28[3][0];
pFrame->unk_3F190[2][1] = -sp28[3][1];
pFrame->unk_3F190[2][2] = -sp28[3][2];
pFrame->unk_3F190[2][3] = -sp28[3][3];
if (sp28[3][0] != 0.0f) {
pFrame->unk_3F1D0[2][2] = -sp28[2][0] / sp28[3][0];
} else if (sp28[3][1] != 0.0f) {
pFrame->unk_3F1D0[2][2] = -sp28[2][1] / sp28[3][1];
} else {
pFrame->unk_3F1D0[2][2] = -sp28[2][2] / sp28[3][2];
}
pFrame->unk_3F1D0[2][3] = -((pFrame->unk_3F1D0[2][2] * pFrame->unk_3F190[2][3]) - sp28[2][3]);
pFrame->unk_3F1D0[3][2] = -1.0f;
pFrame->unk_3F1D0[3][3] = 0.0f;
pFrame->unk_3F1D0[1][2] = 1.0f;
pFrame->unk_3F190[1][0] = sp28[1][0] - pFrame->unk_3F190[2][0];
pFrame->unk_3F190[1][1] = sp28[1][1] - pFrame->unk_3F190[2][1];
pFrame->unk_3F190[1][2] = sp28[1][2] - pFrame->unk_3F190[2][2];
pFrame->unk_3F190[1][3] = sp28[1][3] - pFrame->unk_3F190[2][3];
pFrame->unk_3F1D0[0][2] = 1.0f;
pFrame->unk_3F190[0][0] = sp28[0][0] - pFrame->unk_3F190[2][0];
pFrame->unk_3F190[0][1] = sp28[0][1] - pFrame->unk_3F190[2][1];
pFrame->unk_3F190[0][2] = sp28[0][2] - pFrame->unk_3F190[2][2];
pFrame->unk_3F190[0][3] = sp28[0][3] - pFrame->unk_3F190[2][3];
PSMTXTranspose(pFrame->unk_3F190, pFrame->unk_3F190);
PSMTXTranspose(pFrame->unk_3F1D0, pFrame->unk_3F150);
fn_8004A314_inline(pFrame->unk_3F150, sp18, -1.0f);
fn_8004A314_inline(pFrame->unk_3F150, sp8, 1.0f);
temp_f1_2 = sp8[3] * 0.1f;
temp_f2_4 = sp18[3] + temp_f1_2;
pFrame->unk_3F1D0[2][2] = temp_f1_2 / temp_f2_4;
pFrame->unk_3F1D0[2][3] = temp_f1_2 * sp18[3] / temp_f2_4;
pFrame->unk_3F210 = sp18[3];
pFrame->unk_3F214 = -sp8[3];
pFrame->eTypeProjection = FMP_PERSPECTIVE;
} else {
memcpy(pFrame->unk_3F190, pFrame->matrixProjection, sizeof(Mtx44));
PSMTX44Identity(pFrame->unk_3F1D0);
memcpy(pFrame->unk_3F150, pFrame->unk_3F1D0, sizeof(Mtx44));
pFrame->unk_3F1D0[2][2] = -0.25f;
pFrame->unk_3F1D0[2][3] = -0.5f;
pFrame->unk_3F210 = 1.0f;
pFrame->unk_3F214 = 0.0f;
pFrame->eTypeProjection = FMP_ORTHOGRAPHIC;
}
}
bool frameDrawSetupFog_StarFox(Frame* pFrame) {
GXColor color;
GXFogType nFogType;
f32 rNear;
f32 rFar;
f32 rMultiplier;
f32 rOffset;
f32 rStart;
f32 rEnd;
f32 var_f5;
f32 var_f6;
f32 var_f9;
rMultiplier = (s16)(pFrame->aMode[0] >> 16);
rOffset = (s16)(pFrame->aMode[0] & 0xFFFF);
rFar = pFrame->unk_3F210;
rNear = pFrame->unk_3F214;
color = pFrame->aColor[FCT_FOG];
nFogType = GX_FOG_EXP;
if (rOffset == rMultiplier && rOffset == 0.0f) {
GXSetFog(GX_FOG_NONE, color, 0.0f, 0.0f, 0.0f, 1000.0f);
return true;
}
var_f6 = -rOffset;
var_f9 = var_f6 / rMultiplier;
rStart = pFrame->unk_3F150[3][2] / (var_f9 - (pFrame->unk_3F150[2][2] / pFrame->unk_3F150[2][3]));
var_f5 = 253.0f;
var_f6 = var_f5 + var_f6;
var_f6 = (var_f6) / rMultiplier;
if (rStart < rNear) {
rStart = rNear;
}
if (rStart > rFar) {
rStart = rFar;
}
if (var_f6 > 1.2f) {
nFogType = GX_FOG_EXP;
rStart = -rOffset / rMultiplier;
rEnd = (rMultiplier + rOffset) / 256.0f;
rEnd = 1.0f - rEnd;
rEnd = rEnd * (rFar - rNear) + rNear;
} else {
if (var_f6 > 1.0f) {
var_f6 = 1.0f;
}
rEnd = pFrame->unk_3F150[3][2] / (var_f6 - (pFrame->unk_3F150[2][2] / pFrame->unk_3F150[2][3]));
if (rEnd < rNear) {
rEnd = rNear;
}
if (rEnd > rFar) {
rEnd = rFar;
}
}
rNear *= 0.1f;
if (((pFrame->aMode[FMT_OTHER0] >> 26) & 3) == 1 || (pFrame->aMode[FMT_OTHER0] >> 30) == 3 ||
((pFrame->aMode[FMT_OTHER0] >> 22) & 3) == 3) {
GXSetFog(nFogType, color, rStart, rEnd, rNear, rFar);
} else {
GXSetFog(GX_FOG_NONE, color, 0.0f, 0.0f, 0.0f, 1000.0f);
}
return true;
}
bool frameDrawSetupFog_Default(Frame* pFrame) {
GXColor color;
s32 nFogType;
f32 rNear;
f32 rFar;
f32 rMultiplier;
f32 rOffset;
f32 rStart;
f32 rEnd;
f32 var_f5;
f32 var_f6;
f32 var_f9;
rMultiplier = (s16)(pFrame->aMode[0] >> 16);
rOffset = (s16)(pFrame->aMode[0] & 0xFFFF);
rFar = pFrame->unk_3F210;
rNear = pFrame->unk_3F214;
color = pFrame->aColor[FCT_FOG];
nFogType = GX_FOG_EXP;
if (rOffset == rMultiplier && rOffset == 0.0f) {
GXSetFog(GX_FOG_NONE, color, 0.0f, 0.0f, 0.0f, 1000.0f);
return true;
}
var_f6 = -rOffset;
var_f9 = var_f6 / rMultiplier;
rStart = pFrame->unk_3F150[3][2] / (var_f9 - (pFrame->unk_3F150[2][2] / pFrame->unk_3F150[2][3]));
var_f5 = 249.0f;
var_f6 = var_f5 + var_f6;
var_f6 = var_f6 / rMultiplier;