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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
|
//
// Generated By: dol2asm
// Translation Unit: J2DPictureEx
//
#include "JSystem/JSystem.h" // IWYU pragma: keep
#include "JSystem/J2DGraph/J2DPictureEx.h"
#include "JSystem/J2DGraph/J2DMaterial.h"
#include "JSystem/J2DGraph/J2DScreen.h"
#include "JSystem/JSupport/JSURandomInputStream.h"
#include "JSystem/JUtility/JUTTexture.h"
#include "dolphin/types.h"
/* 80303640-803036EC 2FDF80 00AC+00 1/0 0/0 0/0 .text
* initiate__12J2DPictureExFPC7ResTIMGPC7ResTLUT */
void J2DPictureEx::initiate(ResTIMG const* param_0, ResTLUT const* param_1) {
J2DTexGenBlock* this_00 = mMaterial->getTexGenBlock();
if (this_00->getTexGenNum() == 0 && append(param_0, 1.0f) && param_1 != NULL) {
if (mMaterial->getTevBlock()->getPalette(0) == NULL) {
mMaterial->getTevBlock()->setPalette(0, param_1);
}
}
}
/* 803036EC-8030393C 2FE02C 0250+00 0/0 1/1 0/0 .text
* __ct__12J2DPictureExFP7J2DPaneP20JSURandomInputStreamUlP11J2DMaterial */
J2DPictureEx::J2DPictureEx(J2DPane* param_0, JSURandomInputStream* param_1, u32 param_2,
J2DMaterial* param_3) {
field_0x194 = 0;
field_0x198 = 0;
s32 origPosition = param_1->getPosition();
u32 local_68[2];
param_1->read(local_68, 8);
mKind = local_68[0];
s32 iVar2 = param_1->getPosition();
u32 auStack_70[2];
param_1->peek(auStack_70, 8);
makePaneExStream(param_0, param_1);
param_1->seek(iVar2 + auStack_70[1], JSUStreamSeekFrom_SET);
J2DScrnBlockPictureParameter aJStack_60;
param_1->read(&aJStack_60, sizeof(J2DScrnBlockPictureParameter));
field_0x154 = aJStack_60.mMaterialNum;
field_0x156 = aJStack_60.field_0x4;
for (int i = 0; i < 4; i++) {
field_0x158[i] = aJStack_60.field_0x8[i];
field_0x10a[i] = aJStack_60.field_0x10[i];
mCornerColor[i] = JUtility::TColor(aJStack_60.mCornerColor[i]);
}
param_1->seek(origPosition + local_68[1], JSUStreamSeekFrom_SET);
mMaterial = NULL;
if (field_0x156 != 0xffff) {
mMaterial = param_3 + field_0x156;
(param_3 + field_0x156)->field_0x4 = this;
}
field_0x190 = 0;
mAlpha = 0xff;
rewriteAlpha();
for (int iVar1 = 0; iVar1 < 2; iVar1++) {
field_0x11c[iVar1] = 1.0f;
field_0x124[iVar1] = 1.0f;
}
for (int iVar1 = 0; iVar1 < 6; iVar1++) {
field_0x160[iVar1] = 1.0f;
field_0x178[iVar1] = 1.0f;
}
}
/* 8030393C-803039CC 2FE27C 0090+00 1/0 0/0 0/0 .text __dt__12J2DPictureExFv */
J2DPictureEx::~J2DPictureEx() {
if (field_0x190) {
delete mMaterial;
}
}
/* 803039CC-80303AB4 2FE30C 00E8+00 1/0 0/0 0/0 .text prepareTexture__12J2DPictureExFUc
*/
bool J2DPictureEx::prepareTexture(u8 param_0) {
if (!mMaterial->getTevBlock()->prepareTexture(param_0)) {
return false;
}
for (u8 i = 0; i < param_0; i++) {
J2DTexMtx aJStack_68;
mMaterial->getTexGenBlock()->setTexMtx(i, aJStack_68);
}
return true;
}
/* 80303AB4-80303B80 2FE3F4 00CC+00 1/0 0/0 0/0 .text drawSelf__12J2DPictureExFffPA3_A4_f
*/
void J2DPictureEx::drawSelf(f32 param_0, f32 param_1, f32 (*param_2)[3][4]) {
if (mMaterial != NULL) {
mMaterial->setGX();
GXClearVtxDesc();
GXSetVtxDesc(GX_VA_POS, GX_DIRECT);
GXSetVtxDesc(GX_VA_CLR0, GX_DIRECT);
GXSetVtxDesc(GX_VA_TEX0, GX_DIRECT);
drawFullSet(param_0, param_1, getWidth(), getHeight(), param_2);
}
}
/* 80303B80-80303BDC 2FE4C0 005C+00 1/0 0/0 0/0 .text drawFullSet__12J2DPictureExFffffPA3_A4_f */
void J2DPictureEx::drawFullSet(f32 param_0, f32 param_1, f32 param_2, f32 param_3,
f32 (*param_4)[3][4]) {
drawTexCoord(mBounds.i.x, mBounds.i.y, param_2, param_3, field_0x10a[0].x, field_0x10a[0].y,
field_0x10a[1].x, field_0x10a[1].y, field_0x10a[2].x, field_0x10a[2].y,
field_0x10a[3].x, field_0x10a[3].y, param_4);
}
/* 80303BDC-80303E5C 2FE51C 0280+00 1/0 0/0 0/0 .text
* drawTexCoord__12J2DPictureExFffffssssssssPA3_A4_f */
void J2DPictureEx::drawTexCoord(f32 param_0, f32 param_1, f32 param_2, f32 param_3, s16 param_4,
s16 param_5, s16 param_6, s16 param_7, s16 param_8, s16 param_9,
s16 param_10, s16 param_11, f32 (*param_12)[3][4]) {
f32 dVar12 = param_0 + param_2;
f32 dVar11 = param_1 + param_3;
Mtx auStack_88;
MTXConcat(*param_12, mGlobalMtx, auStack_88);
if (mMaterial == NULL || mMaterial->isVisible()) {
GXLoadPosMtxImm(auStack_88, 0);
JUtility::TColor TStack_8c = mCornerColor[0];
JUtility::TColor TStack_90 = mCornerColor[1];
JUtility::TColor TStack_94 = mCornerColor[2];
JUtility::TColor TStack_98 = mCornerColor[3];
if (mMaterial != NULL) {
if (mMaterial->getColorBlock()->getColorChan(1)->getMatSrc() == 1) {
if (mMaterial->getMaterialAlphaCalc() == 1) {
TStack_8c.a = TStack_8c.a * mColorAlpha / 255;
TStack_90.a = TStack_90.a * mColorAlpha / 255;
TStack_94.a = TStack_94.a * mColorAlpha / 255;
TStack_98.a = TStack_98.a * mColorAlpha / 255;
}
} else if (mIsInfluencedAlpha) {
GXSetChanMatColor(GX_ALPHA0, JUtility::TColor(mColorAlpha));
}
}
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_CLR_RGBA, GX_F32, 0);
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_CLR_RGBA, GX_RGBA4, 8);
GXBegin(GX_QUADS, GX_VTXFMT0, 4);
GXPosition3f32(param_0, param_1, 0.0f);
GXColor1u32(TStack_8c);
GXTexCoord2s16(param_4, param_5);
GXPosition3f32(dVar12, param_1, 0.0f);
GXColor1u32(TStack_90);
GXTexCoord2s16(param_6, param_7);
GXPosition3f32(dVar12, dVar11, 0.0f);
GXColor1u32(TStack_98);
GXTexCoord2s16(param_10, param_11);
GXPosition3f32(param_0, dVar11, 0.0f);
GXColor1u32(TStack_94);
GXTexCoord2s16(param_8, param_9);
GXEnd();
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_CLR_RGBA, GX_RGBX8, 0xf);
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_CLR_RGBA, GX_RGBA4, 0);
}
}
/* 80303E5C-80303EA4 2FE79C 0048+00 1/0 0/0 0/0 .text
* append__12J2DPictureExFPC7ResTIMGP10JUTPalettef */
bool J2DPictureEx::append(ResTIMG const* param_0, JUTPalette* param_1, f32 param_2) {
if (mMaterial == NULL) {
return false;
}
return insert(param_0, param_1, mMaterial->getTexGenBlock()->getTexGenNum(), param_2);
}
/* 80303EA4-80303EEC 2FE7E4 0048+00 1/0 0/0 0/0 .text append__12J2DPictureExFPCcP10JUTPalettef */
bool J2DPictureEx::append(char const* param_0, JUTPalette* param_1, f32 param_2) {
if (mMaterial == NULL) {
return false;
}
return insert(param_0, param_1, mMaterial->getTexGenBlock()->getTexGenNum(), param_2);
}
/* 80303EEC-80303F34 2FE82C 0048+00 1/0 0/0 0/0 .text append__12J2DPictureExFP10JUTTexturef */
bool J2DPictureEx::append(JUTTexture* param_0, f32 param_1) {
if (mMaterial == NULL) {
return false;
}
return insert(param_0, mMaterial->getTexGenBlock()->getTexGenNum(), param_1);
}
/* 80303F34-80303FD8 2FE874 00A4+00 1/0 0/0 0/0 .text
* insert__12J2DPictureExFPC7ResTIMGP10JUTPaletteUcf */
bool J2DPictureEx::insert(ResTIMG const* param_0, JUTPalette* param_1, u8 param_2,
f32 param_3) {
if (param_0 == NULL) {
return false;
}
if (!isInsert(param_2)) {
return false;
}
insertCommon(param_2, param_3);
mMaterial->getTevBlock()->insertTexture(param_2, param_0, param_1);
return true;
}
/* 80303FD8-80304048 2FE918 0070+00 1/0 0/0 0/0 .text insert__12J2DPictureExFPCcP10JUTPaletteUcf
*/
bool J2DPictureEx::insert(char const* param_0, JUTPalette* param_1, u8 param_2, f32 param_3) {
ResTIMG const* resource = (ResTIMG const*)J2DScreen::getNameResource(param_0);
return insert(resource, param_1, param_2, param_3);
}
/* 80304048-803040E4 2FE988 009C+00 1/0 0/0 0/0 .text insert__12J2DPictureExFP10JUTTextureUcf */
bool J2DPictureEx::insert(JUTTexture* param_0, u8 param_1, f32 param_2) {
if (param_0 == NULL) {
return false;
}
if (!isInsert(param_1)) {
return false;
}
insertCommon(param_1, param_2);
mMaterial->getTevBlock()->insertTexture(param_1, param_0);
return true;
}
/* 803040E4-8030437C 2FEA24 0298+00 2/2 0/0 0/0 .text insertCommon__12J2DPictureExFUcf */
void J2DPictureEx::insertCommon(u8 pos, f32 param_1) {
u8 new_tev_stage_num;
u8 tex_gen_num = mMaterial->getTexGenBlock()->getTexGenNum();
mMaterial->getTevBlock()->getMaxStage();
int tev_stage_num = mMaterial->getTevBlock()->getTevStageNum();
bool bVar1;
if (tex_gen_num <= 1) {
bVar1 = tev_stage_num != 1;
} else {
bVar1 = tev_stage_num != tex_gen_num + 1;
}
shiftSetBlendRatio(pos, param_1, true, true);
shiftSetBlendRatio(pos, param_1, false, true);
tex_gen_num++;
mMaterial->getTexGenBlock()->setTexGenNum(tex_gen_num);
J2DTexCoordInfo tex_coord_info;
tex_coord_info.mTexGenType = GX_TG_MTX2x4;
tex_coord_info.mTexGenSrc = GX_TG_TEX0;
for (int i = tex_gen_num - 1; i >= pos; i--) {
tex_coord_info.mTexGenMtx = i * 3 + 30;
J2DTexCoord tex_coord(tex_coord_info);
mMaterial->getTexGenBlock()->setTexCoord((u8)i, tex_coord);
}
for (int i = tex_gen_num - 1; i > pos; i--) {
mMaterial->getTexGenBlock()->setTexMtx((u8)i, mMaterial->getTexGenBlock()->getTexMtx((u8)(i - 1)));
}
J2DTexMtx tex_mtx;
mMaterial->getTexGenBlock()->setTexMtx(pos, tex_mtx);
if (tex_gen_num == 1) {
new_tev_stage_num = 1;
} else {
new_tev_stage_num = tex_gen_num + (bVar1 ? 2 : 1);
}
mMaterial->getTevBlock()->setTevStageNum(new_tev_stage_num);
setTevOrder(tex_gen_num, new_tev_stage_num, bVar1);
setTevStage(tex_gen_num, new_tev_stage_num, bVar1);
setTevKColor(tex_gen_num);
setTevKColorSel(tex_gen_num);
setTevKAlphaSel(tex_gen_num);
}
/* 8030437C-8030446C 2FECBC 00F0+00 2/2 0/0 0/0 .text isInsert__12J2DPictureExCFUc */
bool J2DPictureEx::isInsert(u8 pos) const {
if (mMaterial == NULL) {
return false;
}
if (mMaterial->getTevBlock() == NULL) {
return false;
}
u8 texGenNum = mMaterial->getTexGenBlock()->getTexGenNum();
if (texGenNum >= 8 || pos >= 8 || pos > texGenNum) {
return false;
}
u8 maxStage = mMaterial->getTevBlock()->getMaxStage();
if (maxStage <= 2 && texGenNum != 0) {
return false;
}
if (maxStage == mMaterial->getTevBlock()->getTevStageNum() && texGenNum != 0) {
return false;
}
return true;
}
/* 8030446C-80304608 2FEDAC 019C+00 1/0 0/0 0/0 .text remove__12J2DPictureExFUc */
bool J2DPictureEx::remove(u8 pos) {
if (!isRemove(pos)) {
return false;
}
u8 tex_gen_num = mMaterial->getTexGenBlock()->getTexGenNum();
u8 tev_stage_num = mMaterial->getTevBlock()->getTevStageNum();
bool bVar1 = tev_stage_num == tex_gen_num + 1 ? false : true;
shiftSetBlendRatio(pos, 0.0f, true, false);
shiftSetBlendRatio(pos, 0.0f, false, false);
tex_gen_num--;
mMaterial->getTexGenBlock()->setTexGenNum(tex_gen_num);
mMaterial->getTevBlock()->removeTexture(pos);
if (tex_gen_num != 1) {
tev_stage_num = tex_gen_num + (bVar1 ? 2 : 1);
} else {
tev_stage_num = bVar1 ? 2 : 1;
}
mMaterial->getTevBlock()->setTevStageNum(tev_stage_num);
setTevOrder(tex_gen_num, tev_stage_num, bVar1);
setTevStage(tex_gen_num, tev_stage_num, bVar1);
setTevKColor(tex_gen_num);
setTevKColorSel(tex_gen_num);
setTevKAlphaSel(tex_gen_num);
return true;
}
/* 80304608-8030466C 2FEF48 0064+00 1/0 0/0 0/0 .text remove__12J2DPictureExFv */
bool J2DPictureEx::remove() {
if (mMaterial == NULL) {
return false;
}
if (mMaterial->getTevBlock() == NULL) {
return false;
}
u8 texGenNum = mMaterial->getTexGenBlock()->getTexGenNum();
return remove(texGenNum - 1);
}
/* 8030466C-80304728 2FEFAC 00BC+00 1/0 0/0 0/0 .text remove__12J2DPictureExFP10JUTTexture */
bool J2DPictureEx::remove(JUTTexture* param_0) {
if (mMaterial == NULL) {
return false;
}
if (mMaterial->getTevBlock() == NULL) {
return false;
}
u8 texGenNum = mMaterial->getTexGenBlock()->getTexGenNum();
u8 i;
for (i = 0; i < texGenNum; i++) {
if (mMaterial->getTevBlock()->getTexture(i) == param_0)
break;
}
return remove(i);
}
/* 80304728-8030477C 2FF068 0054+00 1/1 0/0 0/0 .text isRemove__12J2DPictureExCFUc */
bool J2DPictureEx::isRemove(u8 param_0) const {
if (mMaterial == NULL) {
return false;
}
if (mMaterial->getTevBlock() == NULL) {
return false;
}
u8 texGenNum = mMaterial->getTexGenBlock()->getTexGenNum();
if (texGenNum <= param_0 || texGenNum == 1) {
return false;
}
return true;
}
/* 8030477C-80304890 2FF0BC 0114+00 1/0 0/0 0/0 .text draw__12J2DPictureExFffUcbbb */
void J2DPictureEx::draw(f32 param_0, f32 param_1, u8 texNo, bool param_3, bool param_4,
bool param_5) {
if (mMaterial == NULL) {
return;
}
if (mMaterial->getTevBlock() == NULL) {
return;
}
if (!isVisible()) {
return;
}
if (texNo >= mMaterial->getTexGenBlock()->getTexGenNum()) {
return;
}
JUTTexture* texture = mMaterial->getTevBlock()->getTexture(texNo);
if (texture != NULL) {
draw(param_0, param_1, texture->getWidth(), texture->getHeight(),
param_3, param_4, param_5);
}
}
/* 80304890-80304D88 2FF1D0 04F8+00 1/0 0/0 0/0 .text draw__12J2DPictureExFffffbbb */
void J2DPictureEx::draw(f32 param_0, f32 param_1, f32 width, f32 height, bool param_4,
bool param_5, bool param_6) {
if (!isVisible()) {
return;
}
if (mMaterial == NULL) {
return;
}
if (mMaterial->getTevBlock() == NULL) {
return;
}
if (mMaterial->getTexGenBlock()->getTexGenNum() == 0) {
return;
}
mMaterial->setGX();
makeMatrix(param_0, param_1, 0.0f, 0.0f);
GXLoadPosMtxImm(mPositionMtx, GX_PNMTX0);
GXSetCurrentMtx(GX_PNMTX0);
if (!mMaterial->isVisible()) {
return;
}
GXClearVtxDesc();
GXSetVtxDesc(GX_VA_POS, GX_DIRECT);
GXSetVtxDesc(GX_VA_CLR0, GX_DIRECT);
GXSetVtxDesc(GX_VA_TEX0, GX_DIRECT);
mColorAlpha = mAlpha;
JUtility::TColor corner_color[4];
for (int i = 0; i < 4; i++) {
corner_color[i] = mCornerColor[i];
}
if (mMaterial->getMaterialAlphaCalc() == 1) {
for (int i = 0; i < 4; i++) {
corner_color[i].a = (mColorAlpha * corner_color[i].a) / 0xff;
}
}
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0);
GXBegin(GX_QUADS, GX_VTXFMT0, 4);
GXPosition3f32(0.0f, 0.0f, 0.0f);
GXColor1u32(corner_color[0]);
if (!param_6) {
GXTexCoord2u16(param_4 ? 0x8000 : 0, param_5 ? 0x8000 : 0);
} else {
GXTexCoord2u16(param_4 ? 0x8000 : 0, param_5 ? 0 : 0x8000);
}
GXPosition3f32(width, 0.0f, 0.0f);
GXColor1u32(corner_color[1]);
if (!param_6) {
GXTexCoord2u16(param_4 ? 0 : 0x8000, param_5 ? 0x8000 : 0);
} else {
GXTexCoord2u16(param_4 ? 0x8000 : 0, param_5 ? 0x8000 : 0);
}
GXPosition3f32(width, height, 0.0f);
GXColor1u32(corner_color[3]);
if (!param_6) {
GXTexCoord2u16(param_4 ? 0 : 0x8000, param_5 ? 0 : 0x8000);
} else {
GXTexCoord2u16(param_4 ? 0 : 0x8000, param_5 ? 0x8000 : 0);
}
GXPosition3f32(0.0f, height, 0.0f);
GXColor1u32(corner_color[2]);
if (!param_6) {
GXTexCoord2u16(param_4 ? 0x8000 : 0, param_5 ? 0 : 0x8000);
} else {
GXTexCoord2u16(param_4 ? 0 : 0x8000, param_5 ? 0 : 0x8000);
}
GXEnd();
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_S16, 0);
GXSetNumTexGens(0);
GXSetNumTevStages(1);
GXSetTevOp(GX_TEVSTAGE0, GX_PASSCLR);
GXSetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD_NULL, GX_TEXMAP_NULL, GX_COLOR0A0);
for (int i = 0; i < 4; i++) {
GXSetTevSwapModeTable((GXTevSwapSel)i, GX_CH_RED, GX_CH_GREEN, GX_CH_BLUE, GX_CH_ALPHA);
}
GXSetNumIndStages(0);
for (int i = 0; i < 16; i++) {
GXSetTevDirect((GXTevStageID)i);
}
Mtx mtx;
MTXIdentity(mtx);
GXLoadPosMtxImm(mtx, GX_PNMTX0);
GXSetChanCtrl(GX_COLOR0A0, GX_FALSE, GX_SRC_REG, GX_SRC_VTX, GX_LIGHT_NULL, GX_DF_NONE, GX_AF_NONE);
GXSetVtxDesc(GX_VA_TEX0, GX_NONE);
}
/* 80304D88-80304EF0 2FF6C8 0168+00 1/0 0/0 0/0 .text drawOut__12J2DPictureExFffffff */
void J2DPictureEx::drawOut(f32 param_0, f32 param_1, f32 param_2, f32 param_3, f32 param_4,
f32 param_5) {
if (mMaterial == NULL) {
return;
}
if (mMaterial->getTevBlock() == NULL) {
return;
}
if (!isVisible()) {
return;
}
JUTTexture* texture = mMaterial->getTevBlock()->getTexture(0);
if (texture != NULL) {
drawOut(JGeometry::TBox2<f32>(param_0, param_1, param_0 + param_2, param_1 + param_3),
JGeometry::TBox2<f32>(param_4, param_5, param_4 + texture->getWidth(),
param_5 + texture->getHeight()));
}
}
/* 80304EF0-80305264 2FF830 0374+00 1/0 0/0 0/0 .text
* drawOut__12J2DPictureExFRCQ29JGeometry8TBox2<f>RCQ29JGeometry8TBox2<f> */
void J2DPictureEx::drawOut(JGeometry::TBox2<f32> const& param_0,
JGeometry::TBox2<f32> const& param_1) {
if (mMaterial == NULL) {
return;
}
if (mMaterial->getTevBlock() == NULL) {
return;
}
if (!isVisible()) {
return;
}
mMaterial->setGX();
GXClearVtxDesc();
GXSetVtxDesc(GX_VA_POS, GX_DIRECT);
GXSetVtxDesc(GX_VA_CLR0, GX_DIRECT);
GXSetVtxDesc(GX_VA_TEX0, GX_DIRECT);
if (!mMaterial->isVisible()) {
return;
}
mColorAlpha = mAlpha;
JUtility::TColor corner_color[4];
for (int i = 0; i < 4; i++) {
corner_color[i] = mCornerColor[i];
}
if (mMaterial->getMaterialAlphaCalc() == 1) {
for (int i = 0; i < 4; i++) {
corner_color[i].a = (mColorAlpha * corner_color[i].a) / 0xff;
}
}
f32 x1 = (param_0.i.x - param_1.i.x) / param_1.getWidth();
f32 x2 = (param_0.f.x - param_1.f.x) / param_1.getWidth() + 1.0f;
f32 y1 = (param_0.i.y - param_1.i.y) / param_1.getHeight();
f32 y2 = (param_0.f.y - param_1.f.y) / param_1.getHeight() + 1.0f;
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_CLR_RGBA, GX_F32, 0);
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_CLR_RGBA, GX_F32, 0);
GXBegin(GX_QUADS, GX_VTXFMT0, 4);
GXPosition3f32(param_0.i.x, param_0.i.y, 0.0f);
GXColor1u32(corner_color[0]);
GXTexCoord2f32(x1, y1);
GXPosition3f32(param_0.f.x, param_0.i.y, 0.0f);
GXColor1u32(corner_color[1]);
GXTexCoord2f32(x2, y1);
GXPosition3f32(param_0.f.x, param_0.f.y, 0.0f);
GXColor1u32(corner_color[3]);
GXTexCoord2f32(x2, y2);
GXPosition3f32(param_0.i.x, param_0.f.y, 0.0f);
GXColor1u32(corner_color[2]);
GXTexCoord2f32(x1, y2);
GXEnd();
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_CLR_RGBA, GX_RGBA4, 0);
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_CLR_RGBA, GX_RGBX8, 15);
GXSetNumTexGens(0);
GXSetNumTevStages(1);
GXSetTevOp(GX_TEVSTAGE0, GX_PASSCLR);
GXSetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD_NULL, GX_TEXMAP_NULL, GX_COLOR0A0);
for (int i = 0; i < 4; i++) {
GXSetTevSwapModeTable((GXTevSwapSel)i, GX_CH_RED, GX_CH_GREEN, GX_CH_BLUE, GX_CH_ALPHA);
}
GXSetNumIndStages(0);
for (int i = 0; i < 16; i++) {
GXSetTevDirect((GXTevStageID)i);
}
GXSetChanCtrl(GX_COLOR0A0, GX_FALSE, GX_SRC_REG, GX_SRC_VTX, GX_LIGHT_NULL, GX_DF_NONE, GX_AF_NONE);
GXSetVtxDesc(GX_VA_TEX0, GX_NONE);
}
/* 80305264-803052AC 2FFBA4 0048+00 1/0 0/0 0/0 .text load__12J2DPictureExF11_GXTexMapIDUc */
void J2DPictureEx::load(_GXTexMapID param_0, u8 param_1) {
if (mMaterial == NULL) {
return;
}
if (mMaterial->getTevBlock() == NULL) {
return;
}
mMaterial->getTevBlock()->loadTexture(param_0, param_1);
}
/* 803052AC-803053E0 2FFBEC 0134+00 3/3 0/0 0/0 .text setTevOrder__12J2DPictureExFUcUcb
*/
void J2DPictureEx::setTevOrder(u8 param_0, u8 param_1, bool param_2) {
u16 local_30[16];
if (param_0 == 1) {
if (!param_2) {
local_30[0] = 4;
} else {
local_30[0] = 0xff;
local_30[1] = 0xff04;
}
} else {
for (u8 i = 0; i < param_0; i++) {
local_30[i] = (i << 8) | 0xff;
}
if (!param_2) {
local_30[param_0] = 0xff04;
} else {
local_30[param_0] = 0xffff;
local_30[param_0 + 1] = 0xff04;
}
}
for (u8 i = 0; i < param_1; i++) {
J2DTevOrderInfo info;
info.mTexMap = info.mTexCoord = local_30[i] >> 8;
info.mColor = local_30[i] & 0xff;
J2DTevOrder order(info);
mMaterial->getTevBlock()->setTevOrder(i, order);
}
}
/* 803053E0-80305688 2FFD20 02A8+00 3/3 0/0 0/0 .text setTevStage__12J2DPictureExFUcUcb
*/
void J2DPictureEx::setTevStage(u8 param_0, u8 param_1, bool param_2) {
if (param_0 == 1) {
J2DTevStage* stage = mMaterial->getTevBlock()->getTevStage(0);
JUTTexture* texture = mMaterial->getTevBlock()->getTexture(0);
bool bVar1 = false;
if (texture != NULL && texture->getTexInfo() != NULL
&& (texture->getFormat() == 0 || texture->getFormat() == 1)
&& texture->getTransparency() == 0)
{
bVar1 = true;
}
if (!param_2) {
setStage(stage, bVar1 ? STAGE_1 : STAGE_0);
} else {
setStage(stage, bVar1 ? STAGE_6 : STAGE_5);
stage = mMaterial->getTevBlock()->getTevStage(1);
setStage(stage, STAGE_4);
}
} else if (!param_2) {
J2DTevStage* stage = mMaterial->getTevBlock()->getTevStage(0);
setStage(stage, STAGE_2);
for (u8 i = 1; i < param_0; i++) {
stage = mMaterial->getTevBlock()->getTevStage(i);
setStage(stage, STAGE_3);
}
stage = mMaterial->getTevBlock()->getTevStage(param_0);
setStage(stage, STAGE_4);
} else {
J2DTevStage* stage = mMaterial->getTevBlock()->getTevStage(0);
setStage(stage, STAGE_2);
for (u8 i = 1; i < param_0; i++) {
stage = mMaterial->getTevBlock()->getTevStage(i);
setStage(stage, STAGE_3);
}
stage = mMaterial->getTevBlock()->getTevStage(param_0);
setStage(stage, STAGE_7);
stage = mMaterial->getTevBlock()->getTevStage((u8)(param_0 + 1));
setStage(stage, STAGE_4);
}
}
/* 80305688-80305928 2FFFC8 02A0+00 1/1 0/0 0/0 .text
* setStage__12J2DPictureExFP11J2DTevStageQ212J2DPictureEx10stage_enum */
void J2DPictureEx::setStage(J2DTevStage* stage, J2DPictureEx::stage_enum idx) {
s8 colorData[8][4] = {
{0x0F, 0x08, 0x0A, 0x0F},
{0x0F, 0x08, 0x0A, 0x0F},
{0x0F, 0x08, 0x0E, 0x0F},
{0x0F, 0x08, 0x0E, 0x00},
{0x0F, 0x0A, 0x00, 0x0F},
{0x02, 0x04, 0x08, 0x0F},
{0x02, 0x04, 0x08, 0x0F},
{0x02, 0x04, 0x00, 0x0F},
};
s8 alphaData[8][4] = {
{0x07, 0x04, 0x05, 0x07},
{0x05, 0x07, 0x07, 0x07},
{0x07, 0x04, 0x06, 0x07},
{0x07, 0x04, 0x06, 0x00},
{0x07, 0x05, 0x00, 0x07},
{0x01, 0x02, 0x04, 0x07},
{0x07, 0x07, 0x07, 0x02},
{0x01, 0x02, 0x00, 0x07},
};
s8 opData[8][5] = {
{0x00, 0x00, 0x00, 0x01, 0x00},
{0x00, 0x00, 0x00, 0x01, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x01, 0x00},
{0x00, 0x00, 0x00, 0x01, 0x00},
{0x00, 0x00, 0x00, 0x01, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00},
};
stage->setTevColorAB(colorData[idx][0], colorData[idx][1]);
stage->setTevColorCD(colorData[idx][2], colorData[idx][3]);
stage->setTevColorOp(opData[idx][0], opData[idx][1], opData[idx][2], opData[idx][3], opData[idx][4]);
stage->setAlphaABCD(alphaData[idx][0], alphaData[idx][1], alphaData[idx][2], alphaData[idx][3]);
stage->setTevAlphaOp(opData[idx][0], opData[idx][1], opData[idx][2], opData[idx][3], opData[idx][4]);
}
/* 80305928-80305C70 300268 0348+00 5/5 0/0 0/0 .text setTevKColor__12J2DPictureExFUc */
void J2DPictureEx::setTevKColor(u8 param_0) {
if (param_0 == 1) {
return;
}
f32 fVar2 = 0.0f;
f32 fVar3 = 0.0f;
if (param_0 < 2) {
for (u8 i = 0; i < param_0; i++) {
fVar2 += field_0x11c[i];
fVar3 += field_0x124[i];
}
} else {
for (u8 i = 0; i < 2; i++) {
fVar2 += field_0x11c[i];
fVar3 += field_0x124[i];
}
for (u8 i = 0; i < param_0 - 2; i++) {
fVar2 += field_0x160[i];
fVar3 += field_0x178[i];
}
}
u8 local_3c[8];
u8 local_44[8];
for (u8 i = 0; i < 8; i++) {
local_3c[i] = 0xff;
local_44[i] = 0xff;
}
for (u8 i = 0; i < param_0; i++) {
if (i < 2) {
local_3c[i] = field_0x11c[i] * 0xff / fVar2;
local_44[i] = field_0x124[i] * 0xff / fVar3;
} else {
local_3c[i] = field_0x160[i - 2] * 0xff / fVar2;
local_44[i] = field_0x178[i - 2] * 0xff / fVar3;
}
}
JUtility::TColor color[4];
color[3] = local_3c[3] << 24 | local_3c[2] << 16 | local_3c[1] << 8 | local_3c[0];
color[2] = local_3c[7] << 24 | local_3c[6] << 16 | local_3c[5] << 8 | local_3c[4];
color[1] = local_44[3] << 24 | local_44[2] << 16 | local_44[1] << 8 | local_44[0];
color[0] = local_44[7] << 24 | local_44[6] << 16 | local_44[5] << 8 | local_44[4];
for (u8 i = 0; i < 4; i++) {
mMaterial->getTevBlock()->setTevKColor(i, color[i]);
}
}
/* 80305C70-80305D18 3005B0 00A8+00 3/3 0/0 0/0 .text setTevKColorSel__12J2DPictureExFUc
*/
void J2DPictureEx::setTevKColorSel(u8 param_0) {
for (u8 i = 0; i < param_0; i++) {
if (i < 4) {
mMaterial->getTevBlock()->setTevKColorSel(i, 31 - 4 * i);
} else {
mMaterial->getTevBlock()->setTevKColorSel(i, 30 - 4 * (i - 4));
}
}
}
/* 80305D18-80305DC0 300658 00A8+00 3/3 0/0 0/0 .text setTevKAlphaSel__12J2DPictureExFUc
*/
void J2DPictureEx::setTevKAlphaSel(u8 param_0) {
for (u8 i = 0; i < param_0; i++) {
if (i < 4) {
mMaterial->getTevBlock()->setTevKAlphaSel(i, 29 - 4 * i);
} else {
mMaterial->getTevBlock()->setTevKAlphaSel(i, 28 - 4 * (i - 4));
}
}
}
/* 80305DC0-80305ED4 300700 0114+00 2/2 0/0 0/0 .text shiftSetBlendRatio__12J2DPictureExFUcfbb */
void J2DPictureEx::shiftSetBlendRatio(u8 param_0, f32 param_1, bool param_2, bool param_3) {
f32* pJVar4 = param_2 != 0 ? field_0x11c : field_0x124;
f32* local_44 = param_2 != 0 ? field_0x160 : field_0x178;
if (param_3) {
for (int i = 7; i > param_0; i--) {
if (i > 2) {
local_44[i - 2] = local_44[i - 3];
} else if (i == 2) {
local_44[0] = pJVar4[1];
} else {
pJVar4[i] = pJVar4[i - 1];
}
}
if (param_0 >= 2) {
local_44[param_0 - 2] = param_1;
} else {
pJVar4[param_0] = param_1;
}
} else {
for (int i = param_0 + 1; i < 8; i++) {
if (i > 2) {
local_44[i - 3] = local_44[i - 2];
} else if (i == 2) {
pJVar4[1] = local_44[0];
} else {
pJVar4[i - 1] = pJVar4[i];
}
}
}
}
/* 80305ED4-80305F34 300814 0060+00 1/0 0/0 0/0 .text setBlendColorRatio__12J2DPictureExFff */
void J2DPictureEx::setBlendColorRatio(f32 param_0, f32 param_1) {
if (mMaterial == NULL) {
return;
}
field_0x11c[0] = param_0;
field_0x11c[1] = param_1;
for (int i = 0; i < 6; i++) {
field_0x160[i] = 1.0f;
}
setTevKColor(mMaterial->getTexGenBlock()->getTexGenNum());
}
/* 80305F34-80305F94 300874 0060+00 1/0 0/0 0/0 .text setBlendAlphaRatio__12J2DPictureExFff */
void J2DPictureEx::setBlendAlphaRatio(f32 param_0, f32 param_1) {
if (mMaterial == NULL) {
return;
}
field_0x124[0] = param_0;
field_0x124[1] = param_1;
for (int i = 0; i < 6; i++) {
field_0x178[i] = 1.0f;
}
setTevKColor(mMaterial->getTexGenBlock()->getTexGenNum());
}
/* 80305F94-803060DC 3008D4 0148+00 1/0 0/0 0/0 .text changeTexture__12J2DPictureExFPC7ResTIMGUc
*/
const ResTIMG* J2DPictureEx::changeTexture(ResTIMG const* img, u8 param_1) {
if (mMaterial == NULL || img == NULL) {
return NULL;
}
u32 tex_gen_num = mMaterial->getTexGenBlock()->getTexGenNum();
if (param_1 > tex_gen_num) {
return NULL;
}
u8 max_stage = mMaterial->getTevBlock()->getMaxStage();
max_stage = (u8) (max_stage > 8 ? (u8)8 : max_stage);
if (param_1 >= max_stage) {
return NULL;
}
if (param_1 < tex_gen_num) {
const ResTIMG* texinfo = getTexture(param_1)->getTexInfo();
u8 uVar6 = 0;
if (img->indexTexture) {
uVar6 = getUsableTlut(param_1);
}
getTexture(param_1)->storeTIMG(img, uVar6);
return texinfo;
}
append(img, 1.0f);
return NULL;
}
/* 803060DC-80306134 300A1C 0058+00 1/0 0/0 0/0 .text changeTexture__12J2DPictureExFPCcUc
*/
const ResTIMG* J2DPictureEx::changeTexture(char const* param_0, u8 param_1) {
ResTIMG const* resource = (ResTIMG const*)J2DScreen::getNameResource(param_0);
return changeTexture(resource, param_1);
}
/* 80306134-80306298 300A74 0164+00 1/0 0/0 0/0 .text
* changeTexture__12J2DPictureExFPC7ResTIMGUcP10JUTPalette */
const ResTIMG* J2DPictureEx::changeTexture(ResTIMG const* param_0, u8 param_1, JUTPalette* param_2) {
if (mMaterial == NULL || param_0 == NULL) {
return NULL;
}
u32 uVar2 = mMaterial->getTexGenBlock()->getTexGenNum();
if (param_1 > uVar2) {
return NULL;
}
u8 maxStage = mMaterial->getTevBlock()->getMaxStage();
maxStage = (u8) (maxStage > 8 ? (u8) 8 : maxStage);
if (param_1 >= maxStage) {
return NULL;
}
if (param_1 < uVar2) {
const ResTIMG* texInfo = getTexture(param_1)->getTexInfo();
GXTlut _Var7 = GX_TLUT0;
if (param_0->indexTexture != 0) {
_Var7 = getTlutID(param_0, getUsableTlut(param_1));
}
getTexture(param_1)->storeTIMG(param_0, param_2, _Var7);
return texInfo;
}
append(param_0, param_2, 1.0f);
return NULL;
}
/* 80306298-803062F8 300BD8 0060+00 1/0 0/0 0/0 .text
* changeTexture__12J2DPictureExFPCcUcP10JUTPalette */
const ResTIMG* J2DPictureEx::changeTexture(char const* param_0, u8 param_1, JUTPalette* param_2) {
ResTIMG const* resource = (ResTIMG const*)J2DScreen::getNameResource(param_0);
return changeTexture(resource, param_1, param_2);
}
/* 803062F8-80306350 300C38 0058+00 1/0 0/0 0/0 .text getTexture__12J2DPictureExCFUc */
JUTTexture* J2DPictureEx::getTexture(u8 param_0) const {
if (mMaterial == NULL) {
return NULL;
}
if (mMaterial->getTevBlock() == NULL) {
return NULL;
}
return mMaterial->getTevBlock()->getTexture(param_0);
}
/* 80306350-80306370 300C90 0020+00 1/0 0/0 0/0 .text getTextureCount__12J2DPictureExCFv
*/
u8 J2DPictureEx::getTextureCount() const {
if (mMaterial == NULL) {
return NULL;
}
return mMaterial->getTexGenBlock()->getTexGenNum();
}
/* 80306370-803063F8 300CB0 0088+00 1/0 0/0 0/0 .text setBlack__12J2DPictureExFQ28JUtility6TColor
*/
bool J2DPictureEx::setBlack(JUtility::TColor param_0) {
JUtility::TColor black, white;
if (!getBlackWhite(&black, &white)) {
return false;
}
return setBlackWhite(param_0, white);
}
/* 803063F8-80306480 300D38 0088+00 1/0 0/0 0/0 .text setWhite__12J2DPictureExFQ28JUtility6TColor
*/
bool J2DPictureEx::setWhite(JUtility::TColor param_0) {
JUtility::TColor black, white;
if (!getBlackWhite(&black, &white)) {
return false;
}
return setBlackWhite(black, param_0);
}
/* 80306480-80306664 300DC0 01E4+00 1/0 0/0 0/0 .text
* setBlackWhite__12J2DPictureExFQ28JUtility6TColorQ28JUtility6TColor */
bool J2DPictureEx::setBlackWhite(JUtility::TColor param_0, JUtility::TColor param_1) {
if (mMaterial == NULL) {
return false;
}
if (mMaterial->getTevBlock() == NULL) {
return false;
}
if (!isSetBlackWhite(param_0, param_1)) {
return false;
}
bool bVar1;
u8 uVar2;
u8 texGenNum = mMaterial->getTexGenBlock()->getTexGenNum();
bVar1 = true;
if ((param_0 == 0) && (param_1 == 0xffffffff)) {
bVar1 = false;
}
if (texGenNum == 1) {
uVar2 = (bVar1) ? 2 : 1;
} else {
uVar2 = texGenNum + ((bVar1) ? 2 : 1);
}
mMaterial->getTevBlock()->setTevStageNum(uVar2);
setTevOrder(texGenNum, uVar2, bVar1);
setTevStage(texGenNum, uVar2, bVar1);
setTevKColor(texGenNum);
setTevKColorSel(texGenNum);
setTevKAlphaSel(texGenNum);
if (bVar1) {
J2DGXColorS10 local_38;
local_38.r = param_0.r;
local_38.g = param_0.g;
local_38.b = param_0.b;
local_38.a = param_0.a;
mMaterial->getTevBlock()->setTevColor(0, local_38);
local_38.r = param_1.r;
local_38.g = param_1.g;
local_38.b = param_1.b;
local_38.a = param_1.a;
mMaterial->getTevBlock()->setTevColor(1, local_38);
}
return true;
}
/* 80306664-80306824 300FA4 01C0+00 4/4 0/0 0/0 .text
* getBlackWhite__12J2DPictureExCFPQ28JUtility6TColorPQ28JUtility6TColor */
// NONMATCHING regswap
bool J2DPictureEx::getBlackWhite(JUtility::TColor* black, JUtility::TColor* white) const {
if (mMaterial == NULL) {
return false;
}
if (mMaterial->getTevBlock() == NULL) {
return false;
}
u8 tex_gen_num = mMaterial->getTexGenBlock()->getTexGenNum();
u8 tev_stage_num = mMaterial->getTevBlock()->getTevStageNum() & 0xff;
bool bVar1;
if (tex_gen_num == 1) {
bVar1 = tev_stage_num == 1 ? false : true;
} else {
bVar1 = tev_stage_num == tex_gen_num + 1 ? false : true;
}
*black = 0x00000000;
*white = 0xffffffff;
if (bVar1) {
J2DGXColorS10 tevColor0 = *mMaterial->getTevBlock()->getTevColor(0);
J2DGXColorS10 tevColor1 = *mMaterial->getTevBlock()->getTevColor(1);
*black = (u8)tevColor0.r << 24 | (u8)tevColor0.g << 16 | (u8)tevColor0.b << 8 | (u8)tevColor0.a;
*white = (u8)tevColor1.r << 24 | (u8)tevColor1.g << 16 | (u8)tevColor1.b << 8 | (u8)tevColor1.a;
}
return true;
}
/* 80306824-803068F8 301164 00D4+00 1/1 0/0 0/0 .text
* isSetBlackWhite__12J2DPictureExCFQ28JUtility6TColorQ28JUtility6TColor */
bool J2DPictureEx::isSetBlackWhite(JUtility::TColor black, JUtility::TColor white) const {
if (black == 0x00000000 && white == 0xffffffff) {
return true;
}
u8 tex_gen_num = mMaterial->getTexGenBlock()->getTexGenNum();
u32 tev_stage_num = mMaterial->getTevBlock()->getTevStageNum();
u8 max_tev_stage = mMaterial->getTevBlock()->getMaxStage();
if (max_tev_stage == 16) {
return true;
}
if (max_tev_stage == 1) {
return false;
}
u8 tmp = (u8)(tex_gen_num == 1 ? 2 : (tex_gen_num + 2));
return tmp <= max_tev_stage;
}
/* 803068F8-80306958 301238 0060+00 1/0 0/0 0/0 .text getBlack__12J2DPictureExCFv */
JUtility::TColor J2DPictureEx::getBlack() const {
JUtility::TColor black, white;
if (!getBlackWhite(&black, &white)) {
return 0x00000000;
} else {
return black;
}
}
/* 80306958-803069B8 301298 0060+00 1/0 0/0 0/0 .text getWhite__12J2DPictureExCFv */
JUtility::TColor J2DPictureEx::getWhite() const {
JUtility::TColor black, white;
if (!getBlackWhite(&black, &white)) {
return 0xffffffff;
} else {
return white;
}
}
/* 803069B8-803069D8 3012F8 0020+00 1/0 0/0 0/0 .text setAlpha__12J2DPictureExFUc */
void J2DPictureEx::setAlpha(u8 alpha) {
mAlpha = alpha;
if (mMaterial != NULL && mMaterial->getColorBlock()->getMatColor(0) != NULL) {
mMaterial->getColorBlock()->getMatColor(0)->a = alpha;
}
}
/* 803069D8-80306A0C 301318 0034+00 1/0 0/0 0/0 .text setCullBack__12J2DPictureExF11_GXCullMode */
void J2DPictureEx::setCullBack(GXCullMode cullMode) {
mCullMode = cullMode;
if (mMaterial != NULL) {
mMaterial->getColorBlock()->setCullMode(cullMode);
}
J2DPane::setCullBack(cullMode);
}
/* 80306A0C-80306A24 30134C 0018+00 1/0 0/0 0/0 .text rewriteAlpha__12J2DPictureExFv */
void J2DPictureEx::rewriteAlpha() {
if (mMaterial != NULL) {
mAlpha = mMaterial->getColorBlock()->getMatColor(0)->a;
}
}
/* 80306A24-80306AC4 301364 00A0+00 1/0 0/0 0/0 .text isUsed__12J2DPictureExFPC7ResTIMG
*/
bool J2DPictureEx::isUsed(ResTIMG const* texInfo) {
if (mMaterial != NULL && mMaterial->getTevBlock() != NULL) {
for (u32 i = 0; i < 8; i++) {
JUTTexture* texture = mMaterial->getTevBlock()->getTexture(i);
if (texture != NULL && texture->getTexInfo() == texInfo) {
return true;
}
}
}
return J2DPane::isUsed(texInfo);
}
/* 80306AC4-80306AF0 301404 002C+00 1/0 0/0 0/0 .text setAnimation__12J2DPictureExFP11J2DAnmColor
*/
void J2DPictureEx::setAnimation(J2DAnmColor* anm) {
if (mMaterial != NULL) {
mMaterial->setAnimation(anm);
}
}
/* 80306AF0-80306B1C 301430 002C+00 1/0 0/0 0/0 .text
* setAnimation__12J2DPictureExFP19J2DAnmTextureSRTKey */
void J2DPictureEx::setAnimation(J2DAnmTextureSRTKey* anm) {
if (mMaterial != NULL) {
mMaterial->setAnimation(anm);
}
}
/* 80306B1C-80306B48 30145C 002C+00 1/0 0/0 0/0 .text
* setAnimation__12J2DPictureExFP16J2DAnmTexPattern */
void J2DPictureEx::setAnimation(J2DAnmTexPattern* anm) {
if (mMaterial != NULL) {
mMaterial->setAnimation(anm);
}
}
/* 80306B48-80306B74 301488 002C+00 1/0 0/0 0/0 .text
* setAnimation__12J2DPictureExFP15J2DAnmTevRegKey */
void J2DPictureEx::setAnimation(J2DAnmTevRegKey* anm) {
if (mMaterial != NULL) {
mMaterial->setAnimation(anm);
}
}
/* 80306B74-80306B7C -00001 0008+00 0/0 0/0 0/0 .text
* setAnimation__12J2DPictureExFP20J2DAnmVisibilityFull */
void J2DPictureEx::setAnimation(J2DAnmVisibilityFull* anm) {
field_0x194 = anm;
}
/* 80306B7C-80306C70 3014BC 00F4+00 1/0 0/0 0/0 .text
* setAnimation__12J2DPictureExFP14J2DAnmVtxColor */
// NONMATCHING regswap
void J2DPictureEx::setAnimation(J2DAnmVtxColor* anm) {
field_0x198 = anm;
field_0x19c = 0;
if (anm != NULL) {
u16 anm_table_num = anm->getAnmTableNum(0);
for (u8 i = 0; i < 4; i++) {
if (field_0x158[i] != 0xffff) {
for (u16 j = 0; j < anm_table_num; j++) {
J3DAnmVtxColorIndexData* data = anm->getAnmVtxColorIndexData(0, j);
u16* index = anm->getVtxColorIndexPointer(0) + (uintptr_t)data->mpData;
for (u16 k = 0; k < data->mNum; k++) {
if (index[k] == field_0x158[i]) {
field_0x198 = anm;
field_0x19c |= 1 << i;
goto next;
}
}
}
}
next:;
}
}
if (field_0x19c == 0) {
field_0x198 = NULL;
}
}
/* 80306C70-80306DC8 3015B0 0158+00 1/0 0/0 0/0 .text
* animationPane__12J2DPictureExFPC15J2DAnmTransform */
const J2DAnmTransform* J2DPictureEx::animationPane(J2DAnmTransform const* anm) {
if (field_0x194 != NULL && field_0x154 != 0xffff) {
u8 tmp;
field_0x194->getVisibility(field_0x154, &tmp);
if (tmp != 0) {
show();
} else {
hide();
}
}
if (field_0x198 != NULL) {
u16 anm_table_num = field_0x198->getAnmTableNum(0);
for (u8 i = 0; i < 4; i++) {
if (field_0x19c & (1 << i)) {
for (u16 j = 0; j < anm_table_num; j++) {
J3DAnmVtxColorIndexData* data = field_0x198->getAnmVtxColorIndexData(0, j);
u16* index = field_0x198->getVtxColorIndexPointer(0) + (uintptr_t)data->mpData;
for (u16 k = 0; k < data->mNum; k++) {
if (index[k] == field_0x158[i]) {
field_0x198->getColor(0, j, &mCornerColor[i]);
goto next;
}
}
}
}
next:;
}
}
return J2DPane::animationPane(anm);
}
/* 80306DC8-80306ED4 301708 010C+00 1/0 0/0 0/0 .text getUsableTlut__12J2DPictureExFUc */
u8 J2DPictureEx::getUsableTlut(u8 param_0) {
u32 tex_gen_num = mMaterial->getTexGenBlock()->getTexGenNum();
u8 usedTluts = 0;
for (u8 i = 0; i < tex_gen_num; i++) {
JUTTexture* texture = mMaterial->getTevBlock()->getTexture(i);
if (i != param_0 && texture != NULL) {
const ResTIMG* texInfo = texture->getTexInfo();
if (texInfo != NULL && texInfo->indexTexture != 0) {
int tlut_name = texture->getTlutName();
u8 tlut_index = tlut_name - (tlut_name >= GX_BIGTLUT0 ? GX_BIGTLUT0 : GX_TLUT0);
if (tlut_index < 8) {
usedTluts |= 1 << tlut_index;
}
}
}
}
u8 i = 0;
for (; i < 8; i++) {
if (!(usedTluts & (1 << i))) {
return i;
}
}
return 0;
}
/* 80306ED4-80306F04 301814 0030+00 1/0 0/0 0/0 .text append__12J2DPictureExFPC7ResTIMGf
*/
bool J2DPictureEx::append(ResTIMG const* param_0, f32 param_1) {
return append(param_0, NULL, param_1);
}
/* 80306F04-80306F34 301844 0030+00 1/0 0/0 0/0 .text append__12J2DPictureExFPCcf */
bool J2DPictureEx::append(char const* param_0, f32 param_1) {
return append(param_0, NULL, param_1);
}
/* 80306F34-80306F64 301874 0030+00 1/0 0/0 0/0 .text prepend__12J2DPictureExFP10JUTTexturef */
void J2DPictureEx::prepend(JUTTexture* param_0, f32 param_1) {
insert(param_0, 0, param_1);
}
/* 80306F64-80306F94 3018A4 0030+00 1/0 0/0 0/0 .text prepend__12J2DPictureExFPCcP10JUTPalettef */
void J2DPictureEx::prepend(char const* param_0, JUTPalette* param_1, f32 param_2) {
insert(param_0, param_1, 0, param_2);
}
/* 80306F94-80306FC4 3018D4 0030+00 1/0 0/0 0/0 .text prepend__12J2DPictureExFPCcf */
void J2DPictureEx::prepend(char const* param_0, f32 param_1) {
insert(param_0, 0, param_1);
}
/* 80306FC4-80306FF4 301904 0030+00 1/0 0/0 0/0 .text
* prepend__12J2DPictureExFPC7ResTIMGP10JUTPalettef */
void J2DPictureEx::prepend(ResTIMG const* param_0, JUTPalette* param_1, f32 param_2) {
insert(param_0, param_1, 0, param_2);
}
/* 80306FF4-80307024 301934 0030+00 1/0 0/0 0/0 .text prepend__12J2DPictureExFPC7ResTIMGf
*/
void J2DPictureEx::prepend(ResTIMG const* param_0, f32 param_1) {
insert(param_0, 0, param_1);
}
/* 80307024-80307058 301964 0034+00 1/0 0/0 0/0 .text insert__12J2DPictureExFPCcUcf */
bool J2DPictureEx::insert(char const* param_0, u8 param_1, f32 param_2) {
return insert(param_0, NULL, param_1, param_2);
}
/* 80307058-8030708C 301998 0034+00 1/0 0/0 0/0 .text insert__12J2DPictureExFPC7ResTIMGUcf */
bool J2DPictureEx::insert(ResTIMG const* param_0, u8 param_1, f32 param_2) {
return insert(param_0, NULL, param_1, param_2);
}
/* 8030708C-803070D0 3019CC 0044+00 1/0 0/0 0/0 .text draw__12J2DPictureExFffbbb */
void J2DPictureEx::draw(f32 param_0, f32 param_1, bool param_2, bool param_3, bool param_4) {
return draw(param_0, param_1, 0, param_2, param_3, param_4);
}
/* 803070D0-80307134 301A10 0064+00 1/0 0/0 0/0 .text drawOut__12J2DPictureExFffffffff */
void J2DPictureEx::drawOut(f32 param_0, f32 param_1, f32 param_2, f32 param_3, f32 param_4,
f32 param_5, f32 param_6, f32 param_7) {
drawOut(JGeometry::TBox2<f32>(param_0, param_1, param_0 + param_2, param_1 + param_3),
JGeometry::TBox2<f32>(param_4, param_5, param_4 + param_6, param_5 + param_7));
}
/* 80307134-80307168 301A74 0034+00 1/0 0/0 0/0 .text load__12J2DPictureExFUc */
void J2DPictureEx::load(u8 param_0) {
load((GXTexMapID)param_0, param_0);
}
/* 80307168-803071A4 301AA8 003C+00 1/0 0/0 0/0 .text setCullBack__12J2DPictureExFb */
void J2DPictureEx::setCullBack(bool param_0) {
setCullBack(param_0 ? GX_CULL_BACK : GX_CULL_NONE);
}
/* 803071A4-803071C4 301AE4 0020+00 1/0 0/0 0/0 .text isUsed__12J2DPictureExFPC7ResFONT
*/
bool J2DPictureEx::isUsed(ResFONT const* param_0) {
return J2DPane::isUsed(param_0);
}
/* 803071C4-803071E4 301B04 0020+00 1/0 0/0 0/0 .text setAnimation__12J2DPictureExFP10J2DAnmBase
*/
void J2DPictureEx::setAnimation(J2DAnmBase* param_0) {
J2DPane::setAnimation(param_0);
}
|