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
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
|
#ifndef __KAMEK_GAME_H
#define __KAMEK_GAME_H
//#define offsetof(type, member) ((__std(size_t)) &(((type *) 0)->member))
#include <common.h>
#include <rvl/mtx.h>
#include <rvl/GXEnum.h>
#include <rvl/vifuncs.h>
#include <rvl/arc.h>
#define offsetof(type, member) ((u32) &(((type *) 0)->member))
#include <g3dhax.h>
template <typename T>
inline T min(T one, T two) { return (one < two) ? one : two; }
template <typename T>
inline T max(T one, T two) { return (one > two) ? one : two; }
template <typename T>
inline T clamp(T value, T one, T two) { return (value < one) ? one : ((value > two) ? two : value); }
#define M_PI 3.14159265358979323846
#define M_PI_2 (M_PI / 2)
extern "C" {
int wcslen(const wchar_t *str);
wchar_t *wcscpy(wchar_t *dest, const wchar_t *src);
int strlen(const char *str);
char *strcpy(char *dest, const char *src);
char *strncpy(char *dest, const char *src, int num);
int strncmp(const char *str1, const char *str2, int num);
float atan(float x);
float atan2(float y, float x);
float cos(float x);
float sin(float x);
float ceil(float x);
float floor(float x);
}
bool DVD_Start();
bool DVD_End();
bool DVD_StillLoading(void *dvdclass2);
void DVD_LoadFile(void *dvdclass, char *folder, char *file, void *callbackData);
void DVD_FreeFile(void *dvdclass2, char *file);
extern void *DVDClass;
inline void *GetDVDClass() {
return DVDClass;
}
inline void *GetDVDClass2() {
return (void*)(((u32)GetDVDClass())+4);
}
void *DVD_GetFile(void *dvdclass2, const char *arc, const char *file);
void *DVD_GetFile(void *dvdclass2, const char *arc, const char *file, u32 *length);
int MakeRandomNumber(int count);
int MakeRandomNumberForTiles(int count);
extern int Player_Active[4];
extern int Player_ID[4];
extern int Player_Powerup[4];
extern int Player_Flags[4];
extern int Player_Lives[4];
extern int Player_Coins[4];
struct StartLevelInfo {
int maybeUnused;
unsigned char unk1; // 0x04
unsigned char unk2; // 0x05
unsigned char unk3; // 0x06
unsigned char unk4; // 0x07
unsigned int purpose; // 0x08
unsigned char world1; // 0x0C
unsigned char level1; // 0x0D
unsigned char world2; // 0x0E
unsigned char level2; // 0x0F
};
class GMgr8 {
public:
virtual ~GMgr8();
int _4;
float _8, _C;
u32 _10, _14;
u8 _18, _19, _1A, _1B, _1C;
u32 _20, _24, _28, _2C, _30;
};
struct GMgrA0 {
u32 _0, _4, _8;
u8 _C;
};
class GameMgr {
public:
virtual ~GameMgr();
u32 _4;
GMgr8 eight;
u32 _3C, _40, _44, _48, _4C, _50, _54, _58;
u32 _5C, _60, _64, _68, _6C;
u32 _70[10];
u8 _98;
u32 _9C;
GMgrA0 _A0[40];
u32 _320[10], _348[10];
u32 _370, _374, _378, _37C;
u8 switchPalaceFlag;
u32 CharIDs[4];
u8 _394;
u8 _395[10];
u8 _39F[10];
u8 _3A9[10];
u8 _3B3;
u32 numberToInsertInThing[7];
u32 msgCategory, msgID;
u8 _3D8;
u8 currentControllerType, layoutShadowFlag;
u32 numberToInsertInThing10, numberToInsertInThing11;
u32 _3E4, _3E8, _3EC, _3F0, _3F4, _3F8;
// unmapped data from 3FC..AEC (0x6F0)
u8 _3FC[0x6F0];
u32 _AEC, _AF0, _AF4, _AF8;
u8 _AFC, _AFD, _AFE[88];
u8 _B56[4];
u8 _B5A, _B5B;
};
extern GameMgr *GameMgrP;
inline void *GetGameMgr() {
return GameMgrP;
}
bool QueryPlayerAvailability(int id);
void DoStartLevel(void *gameMgr, StartLevelInfo *sl);
// Level Conditions
// 1 : Has Toad Block
// 2 : Is Regular Level (has star coins, etc)
// 0x10 : Has Normal Exit
// 0x20 : Has Secret Exit
// 0x40 : Warp Cannon
// 0x80 : 1up/Green Mushroom House
// 0x100 : Red Mushroom House
// 0x200 : Star/Yellow Mushroom House
void SetSomeConditionShit(int world, int level, unsigned int bits);
bool IsWideScreen();
#define GAMEMGR_GET_AFC(gmgr) (*((bool*)(((u32)(gmgr))+0xAFC)))
#define COND_COIN1 1
#define COND_COIN2 2
#define COND_COIN3 4
#define COND_NORMAL 0x10
#define COND_SECRET 0x20
#define COND_SGNORMAL 0x80
#define COND_SGSECRET 0x100
// All of these are set by "SetWorldCompleteionBitfield" (I didn't name it)
// at 801028D0. It's called by ScStage so it doesn't depend on Nintendo maps.
#define SAVE_BIT_EXISTS_MAYBE 1
// Controls whether you can QUICK SAVE or not.
// Set if 8-Castle is complete.
#define SAVE_BIT_GAME_COMPLETE 2
// Set when all exits are complete.
// This is defined by "ReturnWhetherConditionMaskIsValid" / "SetSomeConditionShit"
// TODO: Need to RE and fix this for Newer...
#define SAVE_BIT_ALL_EXITS 4
// Set when all star coins in worlds 1-8 are obtained.
// Valid levels are chosen by the condition crap as above.
#define SAVE_BIT_ALL_STAR_COINS 8
#define SAVE_BIT_ALL_STAR_COINS_W9 0x10
// Set when, well... EVERYTHING is done.
#define SAVE_BIT_EVERYTHING_TRULY_DONE 0x20
class SaveFirstBlock {
public:
char titleID[4]; // 0x00
u8 field_00; // 0x04
u8 field_01; // 0x05
u8 current_file; // 0x06
u8 field_03; // 0x07
u16 freemode_fav[10][0x2A]; // 0x08
u16 coinbtl_fav[10][0x2A]; // 0x350
u16 bitfield; // 0x698
u16 field_69A; // 0x69A
u32 checksum; // 0x69C
};
class SaveBlock {
public:
u8 field_00; // 0x00
u8 field_01; // 0x01
u8 bitfield; // 0x02
u8 current_world; // 0x03
u8 field_04; // 0x04
u8 current_path_node; // 0x05
u8 field_06; // 0x06
u8 switch_on; // 0x07
u8 field_08; // 0x08
u8 powerups_available[7]; // 0x09
u8 toad_level_idx[10]; // 0x10
u8 player_continues[4]; // 0x1A
u8 player_coins[4]; // 0x1E
u8 player_lives[4]; // 0x22
u8 player_flags[4]; // 0x26
u8 player_type[4]; // 0x2A
u8 player_powerup[4]; // 0x2E
u8 worlds_available[10]; // 0x32
u32 ambush_countdown[10]; // 0x3C
u16 field_64; // 0x64
union {
u16 credits_hiscore; // 0x66
u16 spentStarCoins;
};
u16 score; // 0x68
u32 completions[10][0x2A]; // 0x6C
union {
u8 hint_movie_bought[70]; // 0x6FC
struct {
// ALL Newer additions should go here
// This array has been verified as safe to replace
char newerWorldName[36]; // 0x6FC
GXColor fsTextColours[2]; // 0x720
GXColor fsHintColours[2]; // 0x728
GXColor hudTextColours[2]; // 0x730
s16 hudHintH, hudHintS, hudHintL; // 0x738
u8 currentMapMusic; // 0x73E
u8 _padding; // 0x73F
};
};
u8 toad_location[10]; // 0x742
u8 field_74C[10][4]; // 0x74C
u8 field_774[10][4]; // 0x774
u8 field_79C[10][4]; // 0x79C
u8 death_counts[10][0x2A]; // 0x7C4
u8 death_count_3_4_switch; // 0x968
u8 pad[0x13]; // 0x969
u32 checksum; // 0x97C
u32 GetLevelCondition(int world, int level);
bool CheckLevelCondition(int world, int level, int cond);
bool CheckIfCoinCollected(int world, int level, int num);
};
class SaveFile {
public:
u32 field_00;
u32 field_04;
u32 field_08;
u32 field_0C;
u32 field_10;
u32 field_14;
u32 field_18;
u32 field_1C;
// Real Savefile starts here
SaveFirstBlock header;
SaveBlock blocks[3];
SaveBlock quickSave[3];
SaveBlock *GetBlock(int id);
SaveBlock *GetQSBlock(int id);
bool CheckIfWriting(); // 0x800E0540
};
class SaveHandler {
public:
u8 unknown[0x70];
u32 CurrentState;
u32 CurrentError;
u32 field_7C;
};
extern SaveFile *SaveFileInstance;
extern SaveHandler *SaveHandlerInstance;
inline SaveFile *GetSaveFile() {
return SaveFileInstance;
}
inline SaveHandler *GetSaveHandler() {
return SaveHandlerInstance;
}
#define WPAD_DOWN 0x0001 // Actually Left, but rotated
#define WPAD_UP 0x0002 // Actually Right, but rotated
#define WPAD_RIGHT 0x0004 // Actually Down, but rotated
#define WPAD_LEFT 0x0008 // Actually Up, but rotated
#define WPAD_PLUS 0x0010
#define WPAD_TWO 0x0100
#define WPAD_ONE 0x0200
#define WPAD_B 0x0400
#define WPAD_A 0x0800
#define WPAD_MINUS 0x1000
#define WPAD_HOME 0x8000
struct Remocon {
virtual ~Remocon();
int id;
int controllerType;
u32 untouchedButtons;
u32 lastUntouchedButtons;
u32 heldButtons;
u32 lastHeldButtons;
u32 nowPressed;
u32 _20, _24, _28, _2C, _30;
Vec acc, lastAcc;
Vec2 accVertical, lastAccVertical;
Vec2 vec_5C, lastVec_5C;
Vec2 vec_6C;
Vec2 vec_74, lastVec_74;
float wiimoteMoveDistanceOrSomething;
float lastWiimoteMoveDistanceOrSomething;
u8 isShaking, _8D;
u16 tiltAmount;
u8 _90, _91, _92;
};
struct RemoconMngClass {
void *vtable;
Remocon *controllers[4];
};
/*
* Ok, here's how the remocon/wiimote shit works:
* Remocon is a NSMB-specific class, it handles the different control methods
* and D-pad directions and such automatically.
*
* Wiimote is a generic class (part of EGG) -- well it's not actually called
* that, but who cares. It handles different types of controllers. Only
* query it if whatever you're accessing is control type dependent.
*/
extern RemoconMngClass *RemoconMng;
extern int ActiveWiimoteID;
extern void *ActiveWiimote;
inline RemoconMngClass *GetRemoconMng() {
return RemoconMng;
}
inline int GetActiveWiimoteID() {
return ActiveWiimoteID;
}
inline Remocon *GetActiveRemocon() {
return GetRemoconMng()->controllers[GetActiveWiimoteID()];
}
inline void *GetActiveWiimote() {
return ActiveWiimote;
}
inline unsigned int Remocon_GetButtons(Remocon *self) {
return *((unsigned int*)((u32)self+0x18));
}
inline unsigned int Remocon_GetPressed(Remocon *self) {
return *((unsigned int*)((u32)self+0x1C));
}
typedef bool (*__Wiimote_TestButtons_type)(void*, unsigned int);
inline bool Wiimote_TestButtons(void *self, unsigned int btns) {
VF_BEGIN(__Wiimote_TestButtons_type, self, 8, 0)
return VF_CALL(self, btns);
VF_END;
}
int SearchForIndexOfPlayerID(int id);
bool CheckIfContinueShouldBeActivated();
bool CheckIfMenuShouldBeCancelledForSpecifiedWiimote(int num);
void StartTitleScreenStage(bool realDemo, int sceneParam);
bool CheckIfWeCantDoStuff();
u32 QueryGlobal5758(u32 check);
void SaveGame(void *classDoesntMatter, bool isQuick);
#include <actors.h>
void *CreateParentedObject(short classID, void *parent, int settings, char something);
void *CreateChildObject(short classID, void *parent, int settings, int unk1, int unk2);
#define WIPE_FADE 0
#define WIPE_CIRCLE 1
#define WIPE_BOWSER 2
#define WIPE_WAVY 3
#define WIPE_MARIO 4
#define WIPE_CIRCLE_s 5
void ActivateWipe(int type);
typedef void (*ScreenDrawFunc)();
extern ScreenDrawFunc *CurrentDrawFunc;
void WorldMapDrawFunc();
void GameSetupDrawFunc();
void GameSetup__LoadScene(void *self); // 0x80919560
void FreeScene(int id);
void WpadShit(int unk); // 0x8016F780
void *BgTexMng__LoadAnimTile(void *self, int tileset, short tile, char *name, char *delays, char reverse); // 0x80087B60
extern void *GameHeaps[];
class dFlagMgr_c {
public:
dFlagMgr_c();
enum ActionFlag {
ACTIVATE = 1,
TICKS = 2
};
u64 flags;
float _8[64], _108[64];
u8 _208[64];
u64 _248[64];
u8 _448[64];
u32 ticksRemainingForAction[64];
u8 actionFlag[64];
u32 _5C8[64]; // somehow sound related?! assigned by last param to set(); only checked for == 0
u8 _6C8; // assigned -1 by FlagMgr, and other values by the Switch object, nothing else though
void setup(bool isNewLevel);
void applyAndClearAllTimedActions(); // only used when setup(true) is called
void execute();
void set(u8 number, int delay, bool activate, bool reverseEffect, bool makeNoise, u32 unknown=0);
u8 findLowestFlagInSet(u32 unk, u64 set);
void setSpecial(u8 number, float to8, float to108, u8 to208, u32 unk, u64 to248);
float get8(u8 number);
float get108(u8 number);
u8 get208(u8 number);
u64 get248(u8 number);
u8 get448(u8 number);
// convenience inline functions which may or may not actually exist in Nintendo's original code
u64 mask(u8 number) { return (u64)1 << number; }
bool active(u8 number) { return (flags & mask(number)) != 0; }
bool inactive(u8 number) { return (flags & mask(number)) == 0; }
static dFlagMgr_c *instance;
};
class WLClass {
public:
u32 _0;
u32 _4;
u32 _8;
u32 _otherDatum[38];
static WLClass *instance;
};
class dStage32C_c {
public:
u32 bulletData1[32];
u32 bulletData2[32];
u32 enemyCombos[4];
u32 somethingAboutHatenaBalloons;
u32 redCoinCount[4];
u32 _124[4];
u32 greenCoinsCollected;
u32 hasKilledEnemyThisTick_maybe;
u16 booID;
u32 _bigBooID;
u16 bulletBillCount;
u32 bombCount;
u32 goombaCount;
u32 enemyKillCounter;
u32 another_counter;
u32 freezeMarioBossFlag;
u32 aboutMortonBigPile;
u32 somethingAboutPunchingChainlink;
u32 currentBigHanaMgr;
u32 _16C;
u8 penguinCount;
u32 pokeyTimer;
static dStage32C_c *instance;
};
// No idea if these actually exist or not
class mRect {
public:
float x, y, width, height;
};
class mRect16 {
public:
short x, y, width, height;
};
class mMtx {
Mtx data;
public:
mMtx() { }
mMtx(float _00, float _01, float _02, float _03,
float _10, float _11, float _12, float _13,
float _20, float _21, float _22, float _23);
float* operator[](int row) { return data[row]; }
operator MtxPtr() const { return (MtxPtr)this; }
/* Create New Ones */
void zero();
void identity() { MTXIdentity(data); }
void translation(float x, float y, float z) { MTXTrans(data, x, y, z); }
void scale(float x, float y, float z) { MTXScale(data, x, y, z); }
void rotationX(s16 *amount);
void rotationY(s16 *amount);
void rotationZ(s16 *amount);
/* Applied Manipulations */
void applyTranslation(float x, float y, float z) { MTXTransApply(data, data, x, y, z); }
void applyScale(float x, float y, float z) { MTXScaleApply(data, data, x, y, z); }
void applyRotationX(s16 *amount);
void applyRotationY(s16 *amount);
void applyRotationZ(s16 *amount);
void applyRotationYXZ(s16 *x, s16 *y, s16 *z);
void applyRotationZYX(s16 *x, s16 *y, s16 *z);
/* Get Stuff */
void getTranslation(Vec *target);
void getUnknown(S16Vec *target);
};
namespace nw4r {
namespace math {
float CosFIdx(float);
float SinFIdx(float);
void SinCosFIdx(float *s, float *c, float);
}
namespace ut {
// this isn't 100% accurate because it doesn't use templates
// or detail::LinkListImpl, but oh well
// I don't need the methods anyway.
class LinkListNode {
public:
LinkListNode *next;
LinkListNode *prev;
};
class LinkList {
public:
int count;
LinkListNode initialNode;
};
class Color : public GXColor {
public:
GXColor& operator=(const GXColor &other) {
*((u32*)this) = *((u32*)&other);
return *this;
}
};
class Rect {
public:
f32 left;
f32 top;
f32 right;
f32 bottom;
};
template <class T>
class TagProcessorBase { };
}
namespace lyt {
class Pane; // forward declaration
class DrawInfo;
class AnimTransform; // I'll do these later
class AnimResource;
class AnimationLink;
class ResourceAccessor;
class Group;
class GroupContainer;
namespace detail {
class TexCoordAry {
public:
TexCoordAry();
void Free();
void Reserve(u8 count);
void SetSize(u8 count);
void Copy(const void *source, u8 count);
u8 reservedSize, usedSize;
void *data;
};
}
class Layout {
public:
Layout();
virtual ~Layout();
virtual bool Build(const void *data, ResourceAccessor *resAcc);
virtual AnimTransform *CreateAnimTransform();
virtual AnimTransform *CreateAnimTransform(const void *data, ResourceAccessor *resAcc);
virtual AnimTransform *CreateAnimTransform(const AnimResource &res, ResourceAccessor *resAcc);
virtual void BindAnimation(AnimTransform *anim);
virtual void UnbindAnimation(AnimTransform *anim);
virtual void UnbindAllAnimation();
virtual bool BindAnimationAuto(const AnimResource &res, ResourceAccessor *resAcc);
virtual void SetAnimationEnable(AnimTransform *anim, bool unk);
virtual void CalculateMtx(const DrawInfo &info);
virtual void/*?*/ Draw(const DrawInfo &info);
virtual void/*?*/ Animate(ulong flag);
virtual void/*?*/ SetTagProcessor(ut::TagProcessorBase<wchar_t> *tagProc);
ut::LinkList animations;
Pane *rootPane;
GroupContainer *groupContainer;
float width;
float height;
};
class DrawInfo {
public:
DrawInfo();
virtual ~DrawInfo();
Mtx matrix;
float left;
float top;
float right;
float bottom;
float scaleX;
float scaleY;
float alpha;
u8 _50; // this is actually a bitfield. todo: investigate how CW handles bitfields, and so on
};
class TexMap {
public:
void *image, *palette;
u16 width, height;
f32 minLOD, magLOD;
u16 lodBias, palEntryNum;
struct
{
u32 textureFormat: 4;
u32 mipmap: 1;
u32 wrapS: 2;
u32 wrapT: 2;
u32 minFilter: 3;
u32 magFilter: 1;
u32 biasClampEnable: 1;
u32 edgeLODEnable: 1;
u32 anisotropy: 2;
u32 paletteFormat: 2;
} mBits;
};
class Material {
public:
virtual ~Material();
// cheating a bit here
u8 _[0x3C];
// this is actually a pointer to more stuff, not just texmaps
TexMap *texMaps;
};
class Pane {
public:
//Pane(nw4r::lyt::res::Pane const *); // todo: this struct
Pane(void *);
virtual ~Pane();
virtual void *GetRuntimeTypeInfo() const;
virtual void CalculateMtx(const DrawInfo &info);
virtual void Draw(const DrawInfo &info);
virtual void DrawSelf(const DrawInfo &info);
virtual void Animate(ulong flag);
virtual void AnimateSelf(ulong flag);
virtual ut::Color GetVtxColor(ulong id) const;
virtual void SetVtxColor(ulong id, ut::Color color);
virtual uchar GetColorElement(ulong id) const;
virtual void SetColorElement(ulong id, uchar value);
virtual uchar GetVtxColorElement(ulong id) const;
virtual void SetVtxColorElement(ulong id, uchar value);
virtual Pane *FindPaneByName(const char *name, bool recursive);
virtual Material *FindMaterialByName(const char *name, bool recursive);
virtual void/*?*/ BindAnimation(AnimTransform *anim, bool unk1, bool unk2);
virtual void UnbindAnimation(AnimTransform *anim, bool unk);
virtual void UnbindAllAnimation(bool unk);
virtual void UnbindAnimationSelf(AnimTransform *anim);
virtual ut::LinkListNode *FindAnimationLinkSelf(AnimTransform *anim);
virtual ut::LinkListNode *FindAnimationLinkSelf(const AnimResource &anim);
virtual void SetAnimationEnable(AnimTransform *anim, bool unk1, bool unk2);
virtual void SetAnimationEnable(const AnimResource &anim, bool unk1, bool unk2);
virtual ulong GetMaterialNum() const;
virtual Material *GetMaterial() const;
virtual Material *GetMaterial(ulong id) const;
virtual void LoadMtx(const DrawInfo &info);
void AppendChild(Pane *child);
ut::Rect GetPaneRect(const DrawInfo &info) const;
ut::LinkListNode *AddAnimationLink(AnimationLink *link);
Vec2 GetVtxPos() const;
ut::LinkListNode parentLink;
Pane *parent;
ut::LinkList children;
ut::LinkList animations;
Material *material;
Vec trans;
Vec rotate;
Vec2 scale;
Vec2 size;
Mtx calcMtx;
Mtx effectiveMtx;
float _B4;
u8 alpha;
u8 effectiveAlpha;
u8 origin;
u8 flag;
char name[0x11];
char userdata[9];
u8 paneIsOwnedBySomeoneElse;
u8 _D7;
void SetVisible(bool value) {
if (value)
flag |= 1;
else
flag &= ~1;
}
};
class TextBox : public Pane {
public:
TextBox(void *, void *); // todo: TextBox((res::TextBox const *,ResBlockSet const &))
~TextBox();
void *GetRuntimeTypeInfo() const;
void DrawSelf(const DrawInfo &info);
ut::Color GetVtxColor(ulong id) const;
void SetVtxColor(ulong id, ut::Color color);
uchar GetVtxColorElement(ulong id) const;
void SetVtxColorElement(ulong id, uchar value);
void LoadMtx(const DrawInfo &info);
virtual void AllocStringBuffer(u16 size);
virtual void FreeStringBuffer();
virtual u16 SetString(const wchar_t *str, u16 destOffset = 0);
virtual u16 SetString(const wchar_t *str, u16 destOffset, u16 length);
wchar_t *stringBuf;
ut::Color colour1, colour2;
void *font; // actually a ut::ResFont or whatever
float fontSizeX, fontSizeY;
float lineSpace, charSpace;
void *tagProc; // actually a TagProcessor
u16 bufferLength;
u16 stringLength;
u8 alignment;
u8 flags;
};
class Picture : public Pane {
public:
Picture(void *, void *); // todo: Picture((res::Picture const *,ResBlockSet const &))
~Picture();
void *GetRuntimeTypeInfo() const;
void DrawSelf(const DrawInfo &info);
ut::Color GetVtxColor(ulong id) const;
void SetVtxColor(ulong id, ut::Color color);
uchar GetVtxColorElement(ulong id) const;
void SetVtxColorElement(ulong id, uchar value);
virtual void Append(const GXTexObj &obj);
ut::Color colours[4];
detail::TexCoordAry texCoords;
};
}
namespace g3d {
struct CameraData
{
enum Flag
{
FLAG_CAMERA_LOOKAT = 0x00000001,
FLAG_CAMERA_ROTATE = 0x00000002,
FLAG_CAMERA_AIM = 0x00000004,
MASK_CAMERA = 0x00000007,
FLAG_CMTX_VALID = 0x00000008,
FLAG_PROJ_FLUSTUM = 0x00000010,
FLAG_PROJ_PERSP = 0x00000020,
FLAG_PROJ_ORTHO = 0x00000040,
MASK_PROJ = 0x00000070,
FLAG_PMTX_VALID = 0x00000080,
FLAG_VIEWPORT_JITTER_ABOVE = 0x00000100
};
Mtx cameraMtx;
Mtx44 projMtx;
u32 flags;
VEC3 cameraPos;
VEC3 cameraUp;
VEC3 cameraTarget;
VEC3 cameraRotate;
f32 cameraTwist;
GXProjectionType projType;
f32 projFovy;
f32 projAspect;
f32 projNear;
f32 projFar;
f32 projTop;
f32 projBottom;
f32 projLeft;
f32 projRight;
f32 lightScaleS;
f32 lightScaleT;
f32 lightTransS;
f32 lightTransT;
VEC2 viewportOrigin;
VEC2 viewportSize;
f32 viewportNear;
f32 viewportFar;
u32 scissorX;
u32 scissorY;
u32 scissorWidth;
u32 scissorHeight;
s32 scissorOffsetX;
s32 scissorOffsetY;
};
/* Correct camera
cameraMtx:
1.0 0.0 0.0 -0.0
0.0 1.0 0.0 -0.0
0.0 0.0 1.0 -6000.0
projMtx:
0.002345 0.000000 0.000000 -1.000000
0.000000 0.004386 0.000000 -1.000000
0.000000 0.000000 -0.000005 -0.500000
0.000000 0.000000 0.000000 1.000000
flags: 000000C9 : FLAG_CAMERA_LOOKAT | FLAG_CMTX_VALID | FLAG_PROJ_ORTHO | FLAG_PMTX_VALID
cameraPos: {0, 0, 15}
cameraUp: {0, 1, 0}
cameraTarget: {0, 0, 0}
cameraRotate: {0, 0, 0}
cameraTwist: 0
projType: 1
projFovy: 60
projAspect: 1.333333
projNear: -100000
projFar: 100000
projTop: 456
projBottom: 0
projLeft: 0
projRight: 853
lightScaleS: 0.5
lightScaleT: 0.5
lightTransS: 0.5
lightTransT: 0.5
viewportOrigin: {0,0}
viewportSize: {640,456}
viewportNear: 0
viewportFar: 1
scissorX: 0
scissorY: 0
scissorWidth: 0x280
scissorHeight: 0x1C8
scissorOffsetX: 0
scissorOffsetY: 0
*/
class Camera {
public:
enum PostureType { POSTURE_LOOKAT, POSTURE_ROTATE, POSTURE_AIM };
struct PostureInfo
{
PostureType tp;
VEC3 cameraUp;
VEC3 cameraTarget;
VEC3 cameraRotate;
f32 cameraTwist;
};
private:
CameraData *data;
public:
Camera(CameraData *pCamera);
void Init();
void Init(u16 efbWidth, u16 efbHeight, u16 xfbWidth, u16 xfbHeight, u16 viWidth, u16 viHeight);
//void SetPosition(f32 x, f32 y, f32 z);
void SetPosition(const VEC3 &pos);
//void GetPosition(f32 *px, f32 *py, f32 *pz) const;
void GetPosition(VEC3 *pPos) const;
void SetPosture(const PostureInfo &info);
//void GetPosture(PostureInfo *info) const;
void SetCameraMtxDirectly(const Mtx &mtx);
void GetCameraMtx(Mtx *pMtx) const;
void SetOrtho(f32 top, f32 bottom, f32 left, f32 right, f32 near, f32 far);
//void SetFrustum(f32 top, f32 bottom, f32 left, f32 right, f32 near, f32 far);
void SetPerspective(f32 fovy, f32 aspect, f32 near, f32 far);
void SetProjectionMtxDirectly(const Mtx44 *pMtx);
void GetProjectionMtx(Mtx44 *pMtx) const;
//GXProjectionType GetProjectionType() const;
void SetScissor(u32 xOrigin, u32 yOrigin, u32 width, u32 height);
void SetScissorBoxOffset(s32 xOffset, s32 yOffset);
//void GetScissor(u32 *xOrigin, u32 *yOrigin, u32 *width, u32 *height);
void SetViewport(f32 xOrigin, f32 yOrigin, f32 width, f32 height);
//void SetViewport(f32 xOrigin, f32 yOrigin, f32 width, f32 height, f32 near, f32 far);
void SetViewportZRange(f32 near, f32 far);
void SetViewportJitter(u32 field);
//void SetViewportJitter(f32 xOrigin, f32 yOrigin, f32 width, f32 height, f32 near, f32 far, u32 field);
void GetViewport(f32 *xOrigin, f32 *yOrigin, f32 *width, f32 *height, f32 *near, f32 *far) const;
void GXSetViewport() const;
void GXSetProjection() const;
void GXSetScissor() const;
void GXSetScissorBoxOffset() const;
};
namespace G3DState {
GXRenderModeObj *GetRenderModeObj();
}
}
}
VEC2 GetSomeSizeRelatedBULLSHIT();
Vec CalculateSomethingAboutRatio(float, float, float, float);
float CalculateSomethingElseAboutRatio();
nw4r::g3d::CameraData *GetCameraByID(int id);
namespace EGG { class Screen; };
void DoSomethingCameraRelatedWithEGGScreen(int id, EGG::Screen *screen);
int GetCurrentCameraID(); // 80164C80
void SetCurrentCameraID(int id); // 80164C90
void LinkScene(int id); // 80164D50
void UnlinkScene(int id); // 80164CD0
void SceneCalcWorld(int sceneID); // 80164E10
void SceneCameraStuff(int sceneID); // 80164EA0
void CalcMaterial(); // 80164E90
void DrawOpa(); // 80164F70
void DrawXlu(); // 80164F80
bool ChangeAlphaUpdate(bool enable); // 802D3270
bool ChangeColorUpdate(bool enable); // 802D3210
void DoSpecialDrawing1(); // 8006CAE0
void DoSpecialDrawing2(); // 8006CB40
void SetupLYTDrawing(); // 80163360
void ClearLayoutDrawList(); // 801632B0
void RenderAllLayouts(); // 800067A0
void DrawAllLayoutsBeforeX(int x); // 80163440
void DrawAllLayoutsAfterX(int x); // 801634D0
void DrawAllLayoutsAfterXandBeforeY(int x, int y); // 80163560
void RenderEffects(int v1, int v2); // 80093F10
void RemoveAllFromScnRoot(); // 80164FB0
void Reset3DState(); // 80165000
extern "C" void GXDrawDone(); // 801C4FE0
namespace m2d {
class Base_c /*: public nw4r::ut::Link what's this? */ {
public:
u32 _00;
u32 _04;
Base_c();
virtual ~Base_c();
virtual void draw(); // don't call this directly
void scheduleForDrawing();
u8 drawOrder;
};
class Simple_c : public Base_c {
public:
nw4r::lyt::Layout layout;
nw4r::lyt::DrawInfo drawInfo;
u32 _84;
float _88;
float _8C;
float _90;
u32 _94;
Simple_c();
~Simple_c();
void draw();
virtual void _vf10();
virtual void _vf14();
};
}
namespace EGG {
class Frustum {
public:
int projType; // 0 = ortho, 1 = perspective.. who needs GXEnum.h anyway
int isCentered;
float width;
float height;
float fovy;
float dunno;
float near;
float far;
float center_x_maybe;
float center_y_maybe;
float horizontalMultiplier;
float verticalMultiplier;
float unk3;
short some_flag_bit;
// isCentered might actually be isNotCentered, dunno
Frustum(GXProjectionType projType, Vec2 size, bool isCentered, float near, float far); // 802C6D20
Frustum(Frustum &f); // 802C6D90
virtual ~Frustum(); // 802C75F0
virtual void loadDirectly(); // 802C7050
virtual void loadIntoCamera(nw4r::g3d::Camera cam); // 802C7070
void setOrtho(float top, float bottom, float left, float right, float near, float far); // 802C6DD0
void setFovy(float newFovy); // 802C6F60
void getCenterPointsBasedOnPos(float x, float y, float *destX, float *destY); // 802C6FD0
// no idea what this does
float getSomethingForPerspective(float blah); // 802C7020
protected:
// not all of these might be protected, dunno
void copyAllFields(Frustum &f); // 802C6EE0
static void saveSomething(float f1, float f2, float f3, float f4); // 802C70C0
static void restoreSomething(float *f1, float *f2, float *f3, float *f4); // 802C70E0
void loadPerspective(); // 802C7110
void loadOrtho(); // 802C7140
void setCameraPerspective(nw4r::g3d::Camera cam); // 802C7170
void setCameraOrtho(nw4r::g3d::Camera cam); // 802C71E0
void getPerspectiveProjMtx(Mtx44 *mtx); // 802C7250
void getPerspectiveProjv(float *ptr); // 802C72E0
void getOrthoProjv(float *ptr); // 802C73A0
void getOrthoVars(float *top, float *bottom, float *left, float *right); // 802C7480
};
class Screen : public Frustum {
public:
struct Info {
float viewportX, viewportY, viewportWidth, viewportHeight;
float viewportNearZ, viewportFarZ;
int scissorX, scissorY, scissorWidth, scissorHeight;
int scissorOffsetX, scissorOffsetY;
};
Screen(); // 802D0FB0; creates perspective screen with basic settings
Screen(Screen *pParent, bool isCentered, float m40, float m44, float width, float height); // 802D1080
Screen(Screen &s); // 802D1140
~Screen(); // not called by the retail game.. dunno how to make CodeWarrior do this, who gives a fuck
void loadDirectly();
void loadIntoCamera(nw4r::g3d::Camera cam);
void setSomeVars(bool isCentered, float m40, float m44, float width, float height); // 802D1500
Info *getStructContainingInfo(); // 802D1AB0
void doSomethingWithAPassedMatrix(Mtx m, float f1, float f2, float f3, float f4); // 802D1B40
//protected:
void copyAllFields(Screen &s); // 802D1430
void setParent(Screen *pParent = 0); // 802D1540
void useScreenWidth640(); // 802D15A0
void calculateCrap(); // 802D15D0
bool checkIfFlag1IsSet(); // 802D1B10
Screen *parent; // I think it's the parent screen, anyway ...
float _40, _44, _48, _4C, _50, _54;
Info info;
};
class LookAtCamera /* : public BaseCamera */ {
public:
virtual Mtx *getMatrix();
virtual Mtx *getMatrixAgain();
virtual void callCalculateMatrix();
virtual void calculateMatrix();
virtual void loadMatricesIntoGX();
virtual void _vf1C(); // null
virtual Vec getCamPos();
virtual void doStuffInvolvingVfsAndOtherObject(void *unkType);
virtual void _vf28(); // null
virtual Mtx *getPreviousMatrix();
void assignToNW4RCamera(nw4r::g3d::Camera &cam); // 802BEB70
Vec getStuffFromMatrix(); // 802BEBC0
Vec getMoreStuffFromMatrix(); // 802BEC20
Vec getEvenMoreStuffFromMatrix(); // 802BEC80
private:
Mtx matrix;
Mtx previousMatrix;
public:
Vec camPos, target, camUp;
};
class ProjectOrtho /* : public something? */ {
public:
virtual GXProjectionType getProjectionType();
virtual void setGXProjection();
virtual void _vf10(); // null
virtual VEC2 _vf14(VEC2 *something);
virtual Vec _vf18(float something, /*BaseCamera?*/ LookAtCamera *camera);
virtual Vec _vf1C(float something, /*BaseCamera?*/ LookAtCamera *camera);
virtual Vec _vf20(VEC2 *something);
virtual void _vf24();
virtual void setOrthoOntoCamera(nw4r::g3d::Camera &cam);
virtual void _vf2C(); // null
virtual void setGXProjectionUnscaled(); // does not take aspect ratio into account
ProjectOrtho(); // 802BF6C0
void setVolume(float top, float bottom, float left, float right); // 802BF710
void setDefaults(); // I think? 802BF830
Mtx44 matrix; // unused? dunno
void *_44; // dunno type
float near, far, top, bottom, left, right;
};
}
class TileRenderer {
public:
TileRenderer();
~TileRenderer();
TileRenderer *previous, *next;
u16 tileNumber;
u8 unkFlag, someBool;
float x, y, z;
float scale;
s16 rotation;
u8 unkByte;
u16 getTileNum();
bool getSomeBool();
void setSomeBool(u8 value);
float getX();
float getY();
float getZ();
void setPosition(float x, float y);
void setPosition(float x, float y, float z);
u8 getUnkFlag();
void setVars(float scale); // sets unkFlag=1, rotation=0, unkByte=0
void setVars(float scale, s16 rotation); // sets unkFlag=2, unkByte=0
float getScale();
float getRotationFloat();
s16 getRotation();
u8 getUnkByte();
class List {
public:
u32 count;
TileRenderer *first, *last; // order?
void add(TileRenderer *r);
void remove(TileRenderer *r);
void removeAll();
List();
~List();
};
};
class dActor_c; // forward declaration
class dStageActor_c; // forward declaration
class Physics {
public:
struct Unknown {
Unknown();
~Unknown();
float x, y;
};
struct Info {
float x1, y1, x2, y2; // Might be distance to center/edge like APhysics
void *otherCallback1, *otherCallback2, *otherCallback3;
};
Physics();
~Physics();
dActor_c *owner;
Physics *next, *prev;
u32 _C, _10, _14, _18, _1C, _20, _24, _28, _2C, _30, _34;
void *somePlayer;
u32 _3C;
void *otherCallback1, *otherCallback2, *otherCallback3;
void *callback1, *callback2, *callback3;
float lastX, lastY;
Unknown unkArray[4];
float x, y;
float _88, _8C;
float diameter;
Vec lastActorPosition;
float _A0, _A4, last_A0, last_A4, _B0, _B4;
u32 _B8;
s16 *ptrToRotationShort;
s16 currentRotation;
s16 rotDiff;
s16 rotDiffAlt;
u32 isRound;
u32 _CC;
// Flag 4 is icy
u32 flagsMaybe;
u32 _D4, _D8;
u8 isAddedToList, _DD, layer;
u32 id;
void addToList();
void removeFromList();
void baseSetup(dActor_c *actor, void *otherCB1, void *otherCB2, void *otherCB3, u8 t_DD, u8 layer);
// note: Scale can be a null pointer (in that case, it'll use 1.0)
void setup(dActor_c *actor,
float x1, float y1, float x2, float y2,
void *otherCB1, void *otherCB2, void *otherCB3,
u8 t_DD, u8 layer, Vec2 *scale = 0);
void setup(dActor_c *actor,
Vec2 *p1, Vec2 *p2,
void *otherCB1, void *otherCB2, void *otherCB3,
u8 t_DD, u8 layer, Vec2 *scale = 0);
void setup(dActor_c *actor, Info *pInfo, u8 t_DD, u8 layer, Vec2 *scale = 0);
// radius might be diameter? dunno
void setupRound(dActor_c *actor,
float x, float y, float radius,
void *otherCB1, void *otherCB2, void *otherCB3,
u8 t_DD, u8 layer, Vec2 *scale = 0);
void setRect(float x1, float y1, float x2, float y2, Vec2 *scale = 0);
void setRect(Vec2 *p1, Vec2 *p2, Vec2 *scale = 0);
void setX(float value);
void setY(float value);
void setWidth(float value);
void setHeight(float value);
void setPtrToRotation(s16 *ptr);
void update();
static Physics *globalListHead;
static Physics *globalListTail;
// todo: more stuff that might not be relevant atm
};
class ActivePhysics {
public:
struct Info; // forward declaration
typedef void (*Callback)(ActivePhysics *self, ActivePhysics *other);
struct Info {
float xDistToCenter;
float yDistToCenter;
float xDistToEdge;
float yDistToEdge;
u8 category1;
u8 category2;
u32 bitfield1;
u32 bitfield2;
u16 unkShort1C;
Callback callback;
};
ActivePhysics();
virtual ~ActivePhysics();
dStageActor_c *owner;
u32 _8;
u32 _C;
ActivePhysics *listPrev, *listNext;
u32 _18;
Info info;
u32 _40, _44, _48, _4C;
float firstFloatArray[8];
float secondFloatArray[8];
Vec2 positionOfLastCollision;
u16 result1;
u16 result2;
u16 result3;
u8 collisionCheckType;
u8 chainlinkMode;
u8 layer;
u8 someFlagByte;
u8 isLinkedIntoList;
void clear();
void addToList();
void removeFromList();
void initWithStruct(dActor_c *owner, const Info *info);
void initWithStruct(dActor_c *owner, const Info *info, u8 clMode);
u16 checkResult1(u16 param);
u16 checkResult3(u16 param);
float top();
float bottom();
float yCenter();
float right();
float left();
float xCenter();
// Plus more stuff that isn't needed in the public API, I'm pretty sure.
static ActivePhysics *globalListHead;
static ActivePhysics *globalListTail;
};
#include <statelib.h>
class dActorState_c;
class dActorMultiState_c;
template <class TOwner>
class dStateWrapperBase_c {
public:
dStateWrapperBase_c(TOwner *pOwner) :
manager(&pointless, &executor, &dStateBase_c::mNoState), executor(pOwner) { }
dStateWrapperBase_c(TOwner *pOwner, dState_c<TOwner> *pInitState) :
manager(&pointless, &executor, pInitState), executor(pOwner) { }
virtual ~dStateWrapperBase_c() { }
dStatePointless_c pointless;
dStateExecutor_c<TOwner> executor;
dStateMgr_c manager;
// All these are passed straight through to the manager
virtual void ensureStateHasBegun() { manager.ensureStateHasBegun(); }
virtual void execute() { manager.execute(); }
virtual void endCurrentState() { manager.endCurrentState(); }
virtual void setState(dStateBase_c *pNewState) { manager.setState(pNewState); }
virtual void executeNextStateThisTick() { manager.executeNextStateThisTick(); }
virtual dStateMethodExecutorBase_c *getCurrentStateMethodExecutor() { return manager.getCurrentStateMethodExecutor(); }
virtual dStateBase_c *getNextState() { return manager.getNextState(); }
virtual dStateBase_c *getCurrentState() { return manager.getCurrentState(); }
virtual dStateBase_c *getPreviousState() { return manager.getPreviousState(); }
};
template <class TOwner>
class dStateWrapper_c : public dStateWrapperBase_c<TOwner> {
public:
dStateWrapper_c(TOwner *pOwner) :
dStateWrapperBase_c(pOwner) { }
dStateWrapper_c(TOwner *pOwner, dState_c<TOwner> *pInitState) :
dStateWrapperBase_c(pOwner, pInitState) { }
~dStateWrapper_c() { }
};
class MultiStateMgrBase {
public:
virtual ~MultiStateMgrBase();
dStateWrapper_c<dActorMultiState_c> s1, s2;
dStateWrapper_c<dActorMultiState_c> *ptrToStateMgr;
virtual void ensureStateHasBegun(); // calls vfC on ptrToStateMgr
virtual void execute(); // calls vf10 on ptrToStateMgr
virtual void endCurrentState(); // if (isSecondStateMgr()) { disableSecond(); } else { ptrToStateMgr->_vf14(); }
virtual void setState(dStateBase_c *state); // calls vf18 on ptrToStateMgr
virtual void executeNextStateThisTick(); // calls vf1C on ptrToStateMgr
virtual dStateMethodExecutorBase_c *getCurrentStateMethodExecutor(); // calls vf20 on ptrToStateMgr
virtual dStateBase_c *getNextState(); // calls vf24 on ptrToStateMgr
virtual dStateBase_c *getCurrentState(); // calls vf28 on ptrToStateMgr
virtual dStateBase_c *getPreviousState(); // calls vf2C on ptrToStateMgr
virtual void enableSecondWithState(dStateBase_c *state); // sets ptrToStateMgr to s2, calls vf18 on it
virtual void disableSecond(); // if (isSecondStateMgr()) { ptrToStateMgr->vf14(); ptrToStateMgr = &s1; }
virtual bool isSecondStateMgr();
virtual dStateBase_c *getCurrentStateFromFirst(); // calls vf28 on s1
};
class MultiStateMgr : public MultiStateMgrBase {
public:
// what the fuck does this do
~MultiStateMgr();
};
#define REF_NINTENDO_STATE(NAME) \
static State StateID_##NAME;
#define DECLARE_STATE(NAME) \
static State StateID_##NAME; \
void beginState_##NAME(); \
void executeState_##NAME(); \
void endState_##NAME();
#define CREATE_STATE(CLASS, NAME) \
CLASS::State CLASS::StateID_##NAME \
(#CLASS "::StateID_" #NAME, \
&CLASS::beginState_##NAME, \
&CLASS::executeState_##NAME, \
&CLASS::endState_##NAME);
#define CREATE_STATE_E(CLASS, NAME) \
CREATE_STATE(CLASS, NAME) \
void CLASS::beginState_##NAME() { } \
void CLASS::endState_##NAME() { }
#define USING_STATES(CLASS) \
typedef dState_c<CLASS> State;
struct LinkListEntry {
LinkListEntry *prev;
LinkListEntry *next;
void *owned_obj;
};
struct LinkList {
LinkListEntry *first;
LinkListEntry *last;
// PTMF goes here, but I don't know how to represent it
};
struct OrderedLinkListEntry : LinkListEntry {
u16 order;
u16 _;
};
struct TreeNode {
TreeNode *parent;
TreeNode *child;
TreeNode *prev;
TreeNode *next;
void *owned_obj;
};
struct Tree {
TreeNode *firstNode;
// PTMF goes here, but I don't know how to represent it
};
typedef bool (*ChainedFunc)(void*);
class FunctionChain {
public:
ChainedFunc *functions;
u16 count;
u16 current;
void setup(ChainedFunc *functions, u16 count); // 8015F740
};
class dStageActor_c; // forward declaration
class collisionMgr_c {
public:
collisionMgr_c();
virtual ~collisionMgr_c();
//FIXME params and returns and add more
void Clear1();
void Clear2();
void Init(dStageActor_c*,const u8*,const u8*,const u8*);
void Clear3();
bool CollidedWithTile();
int SomethingSemiImportant(u32);
u32 execute();
u32 s_8006FA40(void *);
u32 s_80070760();
bool s_800707E0();
dStageActor_c* owner;
void* struct1_ptr;
void* struct2_ptr;
void* some_ptr;
Vec3* parent_pos_ptr;
Vec3* parent_last_pos_ptr;
Vec3* parent_speed_ptr;
Vec3 someVelocityThing;
float xDeltaMaybe;
float yDeltaMaybe;
u8 _34[24]; //FIXME
float someFloat;
void* class2DC_ptr; //FIXME
void* another_ptr;
void* ptr_to_ptr_to_underneath_actor;
u8 _5C[44]; //FIXME
u32 bitfield_for_checks;
u32 bitfield_backup;
u32 _90, _94;
u8 which_player_of_parent;
u8 which_controller;
u16 _9A, _9C;
u8 _9E[2]; //FIXME
u32 another_bitfield;
u8 _A4;
u8 _A5[3]; //FIXME
u32 yet_another_bitfield;
u8 _AC;
u8 _AD[3]; //FIXME
u32 directional_bitfields[2]; // left right
u8 flagsB8;
u8 flagsB9;
u8 _BA[2]; //FIXME
u8 _BC, _BD;
u16 _BE;
u8 _C0, _C1;
u16 _C2;
u8 _C4[4]; //FIXME
u16 _C8;
u8 _CA[22]; //FIXME
u8 _E0, _E1, _E2;
u8 _E3; //FIXME
u8 _E4, _E5;
u8 _E6[2]; //FIXME
u32 current_layer_ptr;
u8 current_layer;
u8 _ED[3]; //FIXME
};
class BasicCollider {
public:
BasicCollider();
virtual ~BasicCollider();
virtual void update();
virtual void _vf10();
virtual void _vf14();
void clear();
void addToList();
void removeFromList();
dStageActor_c *owner;
BasicCollider *prev, *next;
/* dRSomething */ void *ptrToRSomething;
float rightX, rightY, leftX, leftY;
float xDiff, yDiff;
float lastLeftX, lastLeftY;
float lineLength;
float leftXDeltaSinceLastCalculation;
u32 flags;
s16 rotation;
u8 type;
u8 _43;
u8 isInList;
u8 _45, _46, _47, _48, _49, _4A;
};
class StandOnTopCollider : public BasicCollider {
public:
StandOnTopCollider();
void update();
void init(dStageActor_c *owner,
float _4C, float _50, float topYOffset,
float rightSize, float leftSize,
s16 rotation, u8 unk_45, Vec2 *scale = 0);
// void init(dStageActor_c *owner,
// Vec2 *fields4C_50, float topYOffset,
// float rightSize, float leftSize,
// s16 rotation, u8 unk_45, Vec2 *scale = 0);
void setLeftAndRight(float left, float right);
void setLeftAndRightScaled(float left, float right, float scaleFactor);
// 4C and 50 might be X/Y offset. Not affected by rotation
float _4C, _50, topYOffset, rightSize, leftSize;
};
class RideableActorCollider : public BasicCollider {
public:
RideableActorCollider();
void update();
void init(dStageActor_c *owner, Vec2 *one, Vec2 *two); // 800DB590
void init(dStageActor_c *owner, float x1, float x2, float y1, float y2); // 800DB620
void setPosition(Vec2 *one, Vec2 *two); // 800DB680
void setPosition(float x1, float x2, float y1, float y2); // 800DB6E0
Vec2 left, right;
};
class freezeMgr_c {
public:
u32 some_count;
u32 ice_timer1;
u32 ice_timer2;
u32 _mstate; //0=not,1=frozen,3=die_coin
u32 _10;
u32 _nstate; //1=countdown,2=meltedNormal
u32 spawns_coin; //1=delete,3=coin
u32 _1C_timerLenType;
u32 _20_defaultTimerLenType;
u32 _24;
u32 _28;
u32 perm_freeze;
u32 _30;
u32 actorIds[12];
void* owner; // _64
freezeMgr_c();
~freezeMgr_c();
//FIXME add params and returns
void doSomethingCool1();
void doSomethingCool2();
void setSomething(u32,u32,u32);
void Create_ICEACTORs(void*,int);
void Delete_ICEACTORs();
void SetIceTimer_pt1();
void SetIceTimer_pt2();
void CheckIceTimer_lte_Value();
void doSomethingCool3();
void doSomethingCool4();
void doSomethingCool5();
void doSomethingCool6();
void DoMeltNormal();
void doSomethingCool7();
void CheckCountdownTimer();
};
class StageActorLight {
public:
virtual void init(void *allocator, int);
virtual void update();
virtual void draw();
// virtual ~StageActorLight();
Vec pos;
float size;
u32 secondClass;
u32 firstClass;
};
class fBase_c {
public:
u32 id;
u32 settings;
u16 name;
u8 _A;
u8 _B;
u8 _C;
u8 _D;
u8 base_type;
u8 _F;
TreeNode link_connect;
OrderedLinkListEntry link_execute;
OrderedLinkListEntry link_draw;
LinkListEntry link_IDlookup;
u32 _50;
u32 _54;
u32 _58;
u32 heap;
fBase_c();
virtual int onCreate();
virtual int beforeCreate();
virtual int afterCreate(int);
virtual int onDelete();
virtual int beforeDelete();
virtual int afterDelete(int);
virtual int onExecute();
virtual int beforeExecute();
virtual int afterExecute(int);
virtual int onDraw();
virtual int beforeDraw();
virtual int afterDraw(int);
virtual void willBeDeleted();
virtual bool moreHeapShit(u32 size, void *parentHeap);
virtual bool createHeap(u32 size, void *parentHeap);
virtual void heapCreated();
virtual ~fBase_c();
void Delete();
fBase_c *GetParent();
fBase_c *GetChild();
fBase_c *GetNext();
bool hasUninitialisedProcesses(); // 80162B60
fBase_c *findNextUninitialisedProcess();
};
class dBase_c : public fBase_c {
public:
u32 _64;
const char *explanation_string;
const char *name_string;
dBase_c();
int beforeCreate();
int afterCreate(int);
int beforeDelete();
int afterDelete(int);
int beforeExecute();
int afterExecute(int);
int beforeDraw();
int afterDraw(int);
~dBase_c();
virtual const char *GetExplanationString();
};
class dScene_c : public dBase_c {
public:
FunctionChain *ptrToInitChain;
dScene_c();
int beforeCreate();
int afterCreate(int);
int beforeDelete();
int afterDelete(int);
int beforeExecute();
int afterExecute(int);
int beforeDraw();
int afterDraw(int);
~dScene_c();
void setInitChain(FunctionChain &initChain) {
ptrToInitChain = &initChain;
}
};
class dActor_c : public dBase_c {
public:
LinkListEntry link_actor;
mMtx matrix;
Vec pos;
Vec last_pos;
Vec pos_delta;
Vec pos_delta2;
Vec scale;
Vec speed;
Vec max_speed;
S16Vec rot;
S16Vec _106;
u32 _10C;
u32 _110;
float y_speed_inc;
u32 _118;
float x_speed_inc;
u32 _120;
bool visible;
dActor_c();
virtual void specialDraw1();
virtual void specialDraw2();
virtual int _vf58();
virtual void _vf5C();
~dActor_c();
void UpdateObjectPosBasedOnSpeedValuesReal();
void HandleXSpeed();
void HandleYSpeed();
};
class dStageActor_c : public dActor_c {
public:
enum StageActorType {
NormalType, PlayerType, YoshiType, EntityType
};
u8 _125;
u32 _128, _12C, _130, _134, _138, _13C;
float _140;
u32 _144;
ActivePhysics aPhysics;
collisionMgr_c collMgr;
u8 classAt2DC[0x34];
float _310, _314;
float spriteSomeRectX, spriteSomeRectY;
float _320, _324, _328, _32C, _330, _334, _338, _33C, _340, _344;
u8 direction;
u8 currentZoneID;
u8 _34A, _34B;
u8 *spriteByteStorage;
u16 *spriteShortStorage;
u16 spriteFlagNum;
u64 spriteFlagMask;
u32 _360;
u16 spriteSomeFlag;
u8 _366, _367;
u32 _368;
u8 eatenState; // 0=normal,2=eaten
u8 _36D;
Vec somethingRelatedToScale;
u32 _37C, _380, _384, _388;
u8 stageActorType;
u8 which_player; // _38D
u8 enableFlag, currentLayerID;
u8 deleteForever;
u8 _391, _392, _padding;
dStageActor_c();
int beforeCreate();
int afterCreate(int);
int beforeDelete();
int afterDelete(int);
int beforeExecute();
int afterExecute(int);
int beforeDraw();
int afterDraw(int);
const char *GetExplanationString();
virtual bool _vf60(); // does stuff with BG_GM
virtual void kill(); // nullsub here, defined in StageActor. probably no params
virtual int _vf68(); // params unknown. return (1) might be bool
virtual u8 *_vf6C(); // returns byte 0x38D
virtual Vec2 _vf70(); // returns Vec Actor.pos + Vec Actor.field_D0
virtual int _vf74(); // params unknown. return (1) might be bool
virtual void _vf78(); // params unknown. nullsub
virtual void _vf7C(); // params unknown. nullsub
virtual void eatIn(); // copies Actor.scale into StageActor.somethingRelatedToScale
virtual void disableEatIn(); // params unknown. nullsub
virtual void _vf88(); // params unknown. nullsub
virtual bool _vf8C(void *other); // dAcPy_c/daPlBase_c? return (1) is probably bool. seems related to EatOut. uses vfA4
virtual bool _vf90(dStageActor_c *other); // does something with scores
virtual void _vf94(void *other); // dAcPy_c/daPlBase_c? modifies This's position
virtual void removeMyActivePhysics();
virtual void addMyActivePhysics();
virtual void returnRegularScale(); // the reverse of vf80, yay
virtual void _vfA4(void *other); // AcPy/PlBase? similar to vf94 but not quite the same
virtual float _vfA8(void *other); // AcPy/PlBase? what DOES this do...? does a bit of float math
virtual void _vfAC(void *other); // copies somethingRelatedToScale into scale, then multiplies scale by vfA8's return
virtual void killedByLevelClear(); // plays Wm_en_burst_s at actor position
virtual void _vfB4(); // params unknown. nullsub
virtual void _vfB8(); // params unknown. nullsub
virtual void _vfBC(); // params unknown. nullsub
virtual void _vfC0(); // params unknown. nullsub
virtual void _vfC4(); // params unknown. nullsub
virtual void _vfC8(Vec2 *p, float f); // does stuff including effects and playing PLAYER_SE_OBJ/GROUP_BOOT/SE_OBJ_CMN_SPLASH
virtual void _vfCC(Vec2 *p, float f); // mostly same as vfC8, but uses PLAYER_SE_OBJ/GROUP_BOOT/SE_OBJ_CMN_SPLASH_LAVA
virtual void _vfD0(Vec2 *p, float f); // mostly same as vfC8, but uses PLAYER_SE_OBJ/GROUP_BOOT/SE_OBJ_CMN_SPLASH_POISON
// I'll add methods as I need them
bool outOfZone(Vec3 pos, float* rect, u8 zone);
bool checkZoneBoundaries(u32 flags); // I think this method is for that, anyway
void Delete(u8 param1); // fBase_c::Delete(void);
~dStageActor_c();
static dStageActor_c *create(Actors type, u32 settings, Vec *pos, S16Vec *rot, u8 layer);
static dStageActor_c *createChild(Actors type, dStageActor_c *parent, u32 settings, Vec *pos, S16Vec *rot, u8 layer);
// these are valid while in onCreate
static u8 *creatingByteStorage; // 0x80429FF4
static u16 creatingFlagID; // 0x80429FF8
static u64 creatingFlagMask; // 0x8042A000
static u8 creatingLayerID; // 0x8042A000
};
class dAc_Py_c : public dStageActor_c {
public:
u8 data[0x1164 - 0x394];
ActivePhysics bPhysics;
ActivePhysics cPhysics;
ActivePhysics dPhysics;
ActivePhysics ePhysics;
dAc_Py_c();
int beforeCreate();
int afterCreate(int);
int beforeDelete();
int afterDelete(int);
int beforeExecute();
int afterExecute(int);
int beforeDraw();
int afterDraw(int);
~dAc_Py_c();
};
/* TODO
class dActorState_c : public dStageActor_c {
public:
~dActorState_c();
virtual void _vfD4();
virtual void _vfD8();
virtual void _vfDC();
};
*/
class dActorMultiState_c : public dStageActor_c {
public:
~dActorMultiState_c();
MultiStateMgr acState;
virtual void doStateChange(dStateBase_c *state); // might return bool? overridden by dEn_c
virtual void _vfD8(); // nullsub ??
virtual void _vfDC(); // nullsub ??
virtual void _vfE0(); // nullsub ??
};
class dEn_c : public dActorMultiState_c {
public:
float _414, _418, _41C, _420;
void *nextState;
u32 _428, _42C;
u8 _430, _431, isDead;
u32 _434;
u16 _438;
u32 _43C;
Vec velocity1, velocity2;
u8 _458, _459, _45A, _45B, _45C, _45D, _45E;
u32 _460;
Vec initialScale;
float _470;
u32 _474, _478;
dEn_c *_47C;
u32 _480;
//FIXME verify that size fits
//u8 classAt484[0x4EC - 0x484];
freezeMgr_c frzMgr;
u32 _4EC;
float _4F0, _4F4, _4F8;
u32 flags_4FC;
u16 counter_500, counter_502;
u16 counter_504[4];
u16 counter_50C;
u32 _510, _514, _518;
void *_51C;
dEn_c *_520;
dEn_c();
int afterCreate(int);
int beforeExecute(int);
int afterExecute(int);
int beforeDraw(int);
void kill();
void eatIn();
void disableEatIn();
bool _vf8C(void *other); // AcPy/PlBase?
void _vfAC();
void _vfCC(Vec2 *p, float f);
void _vfD0(Vec2 *p, float f);
void doStateChange(dStateBase_c *state); // might return bool, dunno
// Now here's where the fun starts.
virtual bool preSpriteCollision(ActivePhysics *apThis, ActivePhysics *apOther);
virtual bool prePlayerCollision(ActivePhysics *apThis, ActivePhysics *apOther);
virtual bool preYoshiCollision(ActivePhysics *apThis, ActivePhysics *apOther);
virtual bool stageActorCollision(ActivePhysics *apThis, ActivePhysics *apOther);
virtual void spriteCollision(ActivePhysics *apThis, ActivePhysics *apOther);
virtual void playerCollision(ActivePhysics *apThis, ActivePhysics *apOther);
virtual void yoshiCollision(ActivePhysics *apThis, ActivePhysics *apOther);
// WHAT A MESS
virtual void collisionCat3_StarPower(ActivePhysics *apThis, ActivePhysics *apOther);
virtual void collisionCat5_Mario(ActivePhysics *apThis, ActivePhysics *apOther);
virtual void _vf108(ActivePhysics *apThis, ActivePhysics *apOther);
virtual void collisionCatD_GroundPound(ActivePhysics *apThis, ActivePhysics *apOther);
virtual void _vf110(ActivePhysics *apThis, ActivePhysics *apOther);
virtual void collisionCat8_FencePunch(ActivePhysics *apThis, ActivePhysics *apOther);
virtual void collisionCat7_WMWaggleWater(ActivePhysics *apThis, ActivePhysics *apOther);
virtual void collisionCat7_WMWaggleWaterYoshi(ActivePhysics *apThis, ActivePhysics *apOther);
virtual void _vf120(ActivePhysics *apThis, ActivePhysics *apOther);
virtual void collisionCatA_PenguinMario(ActivePhysics *apThis, ActivePhysics *apOther);
virtual void collisionCat11_PipeCannon(ActivePhysics *apThis, ActivePhysics *apOther);
virtual void collisionCat9_RollingObject(ActivePhysics *apThis, ActivePhysics *apOther);
virtual void collisionCat1_Fireball_E_Explosion(ActivePhysics *apThis, ActivePhysics *apOther);
virtual bool collisionCat2_IceBall_15_YoshiIce(ActivePhysics *apThis, ActivePhysics *apOther);
virtual void collisionCat13_Hammer(ActivePhysics *apThis, ActivePhysics *apOther);
virtual void collisionCat14_YoshiFire(ActivePhysics *apThis, ActivePhysics *apOther);
virtual void _vf140(dStageActor_c *actor);
virtual void _vf144(int something);
virtual void _vf148(); // deletes actors held by Class484 and other stuff
virtual void _vf14C(); // deletes actors held by Class484 and makes an En Coin Jump
virtual u32 _vf150(); // reads some bits from a value in Class1EC
virtual void eatenByYoshiProbably(); // nullsub, params unknown
virtual void playHpdpSound1(); // plays PLAYER_SE_EMY/GROUP_BOOT/SE_EMY_DOWN_HPDP_S or _H
virtual void playEnemyDownSound1();
virtual void playEnemyDownComboSound(void *player); // AcPy_c/daPlBase_c?
virtual void playHpdpSound2(); // plays PLAYER_SE_EMY/GROUP_BOOT/SE_EMY_DOWN_HPDP_S or _H
virtual void _vf168(); // nullsub, params unknown
// State Functions
virtual void dieFumi_Begin(); // does something involving looping thruogh players
virtual void dieFumi_Execute(); // does movement and some other stuff
virtual void dieFumi_End(); // nullsub
virtual void dieFall_Begin(); // does something involving looping thruogh players
virtual void dieFall_Execute(); // does movement and some other stuff
virtual void dieFall_End(); // nullsub
virtual void dieBigFall_Begin(); // calls vf178 [dieFall_Begin]
virtual void dieBigFall_Execute(); // does movement and some other stuff (but less than 170 and 17C)
virtual void dieBigFall_End(); // calls vf180 [dieFall_End]
virtual void dieSmoke_Begin(); // spawns Wm_en_burst_m effect and then removeMyActivePhysics
virtual void dieSmoke_Execute(); // deletes actor with r4=1
virtual void dieSmoke_End(); // nullsub
virtual void dieYoshiFumi_Begin(); // spawns Wm_mr_yoshistep effect and then removeMyActivePhysics
virtual void dieYoshiFumi_Execute(); // deletes actor with r4=1
virtual void dieYoshiFumi_End(); // nullsub
virtual void dieIceVanish_Begin(); // lots of weird stuff
virtual void dieIceVanish_Execute(); // deletes actor with r4=1
virtual void dieIceVanish_End(); // nullsub
virtual void dieGoal_Begin(); // nullsub
virtual void dieGoal_Execute(); // nullsub
virtual void dieGoal_End(); // nullsub
virtual void dieOther_Begin(); // deletes actor with r4=1
virtual void dieOther_Execute(); // nullsub
virtual void dieOther_End(); // nullsub
virtual void eatIn_Begin(); // nullsub
virtual void eatIn_Execute(); // changes to EatNow on one condition, otherwise calls vfAC
virtual void eatIn_End(); // nullsub
virtual void eatNow_Begin(); // nullsub
virtual void eatNow_Execute(); // nullsub
virtual void eatNow_End(); // nullsub
virtual void eatOut_Begin(); // nullsub
virtual void eatOut_Execute(); // nullsub
virtual void eatOut_End(); // nullsub
virtual void hitSpin_Begin(); // nullsub
virtual void hitSpin_Execute(); // nullsub
virtual void hitSpin_End(); // nullsub
virtual void ice_Begin(); // does stuff with Class484 and lots of vf's
virtual void ice_Execute(); // tons of stuff with Class484
virtual void ice_End(); // sets a field in Class484 to 0
virtual void spawnHitEffectAtPosition(Vec2 pos);
virtual void doSomethingWithHardHitAndSoftHitEffects(Vec pos);
virtual void playEnemyDownSound2();
virtual void add2ToYSpeed();
virtual bool _vf218(); // stuff with floats and camera
virtual void _vf21C(); // does stuff with the speeds
virtual void _vf220(void *other); // some type of actor, PlBase? calls vf3F4 on other with r4=this, r5=0
virtual void _vf224(); // stores a couple of values into the struct at 464
virtual void _vf228(); // more fun stuff with 464 and floats
virtual bool CreateIceActors(); // does stuff involving ICE_ACTORs and arrays
virtual void _vf230(); // "relatedToPlayerOrYoshiCollision" apparently. nullsub, params unknown for now.
virtual void _vf234(); // nullsub, params unknown
virtual void _vf238(); // calls vf34 on class394, params unknown
virtual void _vf23C(); // nullsub, params unknown
virtual void _vf240(); // nullsub, params unknown
virtual int _vf244(); // returns 0. might be bool. params unknown
virtual int _vf248(int something); // does some math involving field510 and [7,7,4,0] and param
virtual void _vf24C(void *other); // deals with something in the class involving the bahp flag
virtual void addScoreWhenHit(void *other); // Other is dPlayer
virtual void _vf254(void *other);
virtual void _vf258(void *other);
virtual void _vf25C(void *other); // calls vf250
virtual void _vf260(void *other); // AcPy/PlBase? plays the SE_EMY_FUMU_%d sounds based on some value
virtual void _vf264(dStageActor_c *other); // if other is player or yoshi, do Wm_en_hit and a few other things
virtual void _vf268(void *other); // AcPy/PlBase? plays the SE_EMY_DOWN_SPIN_%d sounds based on some value
virtual void spawnHitEffectAtPositionAgain(Vec2 pos);
virtual void playMameStepSound(); // SE_EMY_MAME_STEP at actor position
virtual void _vf274(); // nullsub, params unknown
virtual void _vf278(void *other); // AcPy/PlBase? plays the SE_EMY_YOSHI_FUMU_%d sounds based on some value
virtual void _vf27C(); // nullsub, params unknown
~dEn_c();
static void collisionCallback(ActivePhysics *one, ActivePhysics *two);
void doSpriteMovement();
bool CheckIfPlayerBelow(float,float);
void stuffRelatingToCollisions(float, float, float);
void checkLiquidImmersionAndKillIfTouchingLava(Vec *pos, float effectScale);
void checkLiquidImmersion(Vec2 *effectivePosition, float effectScale);
// States
USING_STATES(dEn_c);
REF_NINTENDO_STATE(DieFumi);
REF_NINTENDO_STATE(DieFall);
REF_NINTENDO_STATE(DieBigFall);
REF_NINTENDO_STATE(DieSmoke);
REF_NINTENDO_STATE(DieIceVanish);
REF_NINTENDO_STATE(DieYoshiFumi);
REF_NINTENDO_STATE(DieGoal);
REF_NINTENDO_STATE(DieOther);
};
class daEnBlockMain_c : public dEn_c {
public:
u32 _534, _528, _52C, _530;
Physics physics;
float _618, _61C, _620;
u32 _624, _628, _62C;
float initialY;
float _634, _638, _63C, _640;
u32 countdown, _648, _64C;
u32 _650, _654, _658, _65C;
u16 _660;
u8 _662, _663, _664, _665, _666, _667;
u8 _668, _669, _66A, _66B, _66C, _66D, _66E, _66F;
u8 _670, _671, _672, _673;
u8 _674;
u8 _675, _676, _677, _678, _679, _67A, _67B, _67C;
u8 _67D, _67E, _67F, _680;
u32 _684;
u8 _688, isGroundPound, anotherFlag, _68B, _68C, _68D, _68E, _68F;
u32 _690;
u8 _694;
// Regular methods
void blockInit(float initialY);
void blockUpdate();
u8 blockResult();
virtual void calledWhenUpMoveBegins();
virtual void calledWhenDownMoveBegins();
virtual void calledWhenUpMoveExecutes();
virtual void calledWhenUpMoveDiffExecutes();
virtual void calledWhenDownMoveExecutes();
virtual void calledWhenDownMoveEndExecutes();
virtual void calledWhenDownMoveDiffExecutes();
virtual void calledWhenDownMoveDiffEndExecutes();
virtual void updateScale(bool movingDown);
// State functions
virtual void upMove_Begin();
virtual void upMove_Execute();
virtual void upMove_End();
virtual void downMove_Begin();
virtual void downMove_Execute();
virtual void downMove_End();
virtual void downMoveEnd_Begin();
virtual void downMoveEnd_Execute();
virtual void downMoveEnd_End();
virtual void upMove_Diff_Begin();
virtual void upMove_Diff_Execute();
virtual void upMove_Diff_End();
virtual void downMove_Diff_Begin();
virtual void downMove_Diff_Execute();
virtual void downMove_Diff_End();
virtual void downMove_DiffEnd_Begin();
virtual void downMove_DiffEnd_Execute();
virtual void downMove_DiffEnd_End();
static void *PhysicsCallback1;
static void *PhysicsCallback2;
static void *PhysicsCallback3;
static void *OPhysicsCallback1;
static void *OPhysicsCallback2;
static void *OPhysicsCallback3;
USING_STATES(daEnBlockMain_c);
REF_NINTENDO_STATE(UpMove);
REF_NINTENDO_STATE(DownMove);
REF_NINTENDO_STATE(DownMoveEnd);
REF_NINTENDO_STATE(UpMove_Diff);
REF_NINTENDO_STATE(DownMove_Diff);
REF_NINTENDO_STATE(DownMove_DiffEnd);
~daEnBlockMain_c();
};
class daKameckDemo : public dEn_c {
public:
USING_STATES(daKameckDemo);
REF_NINTENDO_STATE(DemoWait);
REF_NINTENDO_STATE(DemoSt);
REF_NINTENDO_STATE(DemoSt2);
};
class daBossKoopa_c : public dEn_c {
public:
USING_STATES(daBossKoopa_c);
REF_NINTENDO_STATE(Fall);
};
class daNeedles : public dEn_c {
public:
USING_STATES(daNeedles);
REF_NINTENDO_STATE(DemoWait);
REF_NINTENDO_STATE(DemoAwake);
REF_NINTENDO_STATE(Idle);
REF_NINTENDO_STATE(Die);
};
class dPlayer : public dActorMultiState_c {
public:
USING_STATES(dPlayer);
REF_NINTENDO_STATE(None);
REF_NINTENDO_STATE(Walk);
REF_NINTENDO_STATE(Jump);
REF_NINTENDO_STATE(DemoNone);
REF_NINTENDO_STATE(DemoWait);
REF_NINTENDO_STATE(DemoGoal);
REF_NINTENDO_STATE(DemoControl);
};
class BgGmBase : public dBase_c {
public:
// TODO, a lot
u16 *getPointerToTile(int x, int y, int layer, int *pBlockNum = 0, bool unused = false);
// Note: these tile numbers are kinda weird and involve GetTileFromTileTable
void placeTile(u16 x, u16 y, int layer, int tile);
};
class dBgGm_c : public BgGmBase {
public:
// TODO TODO TODO TODO TODO
static dBgGm_c *instance;
TileRenderer::List *getTileRendererList(int index);
};
class dPlayerModelBase_c {
// dunno what's public and what's private here
// don't really care
public:
dPlayerModelBase_c(u8 player_id); // 800D5420
virtual ~dPlayerModelBase_c(); // 800D55D0
char allocator[28]; // actually a mHeapAllocatorSubclass but I don't have that
u32 _20;
u32 _24;
char someAnimation[2][0x38]; // actually PlayerAnim's
char yetAnotherAnimation[40]; // actually m3d::banm_c afaics -- is it even 40 bytes?
Vec HeadPos; // maybe not an array
Vec HatPos; // maybe not an array
Mtx finalMatrix;
Mtx firstMatrix;
Vec headOffs;
Vec pos;
u8 player_id_1;
u8 player_id_2;
u8 powerup_id;
u8 powerup_tex;
int current_anim;
int last_anim_maybe;
u32 _15C;
int someFlags;
u32 _164;
u32 _168; // related to jump_strings
u32 _16C;
u32 _170;
u32 _174;
u8 _178;
char padding[3]; // not needed?
u32 model_visibility_flags_maybe;
u32 mode_maybe;
float _184;
float _188;
u32 _18C;
char someArray[6][12]; // some unknown class/struct
char _1D8[0x24];
short _1FC;
short _1FE;
short _200;
char padding_[2]; // not needed?
u32 _204;
u32 _208;
class ModelThing {
public:
m3d::mdl_c body, head;
};
virtual int _vf0C(); // 800D6DA0
virtual void prepare(); // 800D5720
virtual void finaliseModel(); // 800D5740
virtual void update(); // 800D5750
virtual void update3DStuff(); // 800D5760
virtual void _vf20(); // 800D6D90
virtual void draw(); // 800D5C70
virtual ModelThing *getCurrentModel(); // 800D5870
virtual int getCurrentResFile(); // 800D62D0
virtual void setPowerup(u8 powerup_id); // 800D5730
virtual void setPowerupTexture(); // 800D5CC0
virtual void _vf38(); // 800D6D80
virtual void _vf3C(); // 800BD750
virtual void _vf40(); // 800D6D70
virtual void _vf44(); // 800D6D60
virtual void _vf48(); // 800BD740
virtual void _vf4C(); // 800BD730
virtual void getModelMatrix(u32 unk, MtxPtr dest); // 800D5820
virtual int _vf54(); // 80318D0C
virtual bool _vf58(int type, char *buf, bool unk); // 800D6930
virtual void startAnimation(int id, float frame, float unk, float updateRate); // 800D5EC0
virtual int _vf60(); // 800D6920
virtual void _vf64(int id, float unk1, float unk2, float unk3); // 800D62F0
virtual void _vf68(int id, float unk); // 800D63E0
virtual void _vf6C(); // 800D62E0
virtual void _vf70(); // 800D6690
virtual void _vf74(); // 800D66A0
virtual void _vf78(); // 800D66B0
virtual void SomethingRelatedToPenguinAnims(); // 800D66C0
virtual void _vf80(); // 800D6A20
virtual void _vf84(float frame); // 800D5D00
virtual void _vf88(float frame); // 800D5D70
virtual void _vf8C(float updateRate); // 800D5D80
virtual void setUpdateRateForAnim1(float updateRate); // 800D5DF0
virtual void _vf94(); // 800D6D40
virtual int _vf98(); // 800D6D30
virtual void _vf9C(); // 800D6D20
virtual int _vfA0(); // 800D6D10
virtual void _vfA4(); // 800D6D00
virtual int _vfA8(); // 800D6CF0
virtual void _vfAC(bool blah); // 800BD720
// I won't even bother with non-virtual functions....
};
class dPlayerModel_c : public dPlayerModelBase_c {
public:
// methods? what do you need those for...
// (not bothering with them either)
nw4r::g3d::ResFile modelResFile, animResFile1, animResFile2;
u8 effectClass0[296];
u8 effectClass1[296];
ModelThing models[4];
// maybe these are mAllocator_c?
u8 body_switch_animation[12];
mHeapAllocator_c allocator0;
u32 anim0linked;
u8 anim1[12];
mHeapAllocator_c allocator1;
u32 anim1linked;
u8 headSwitchAnimation[12];
mHeapAllocator_c allocator2;
u32 anim2linked;
u8 animForProp[12];
mHeapAllocator_c allocator3;
u32 anim3linked;
u8 animForPeng[12];
mHeapAllocator_c allocator4;
u32 anim4linked;
u8 anim5[12];
mHeapAllocator_c allocator5;
u32 anim5linked;
u32 currentPlayerModelID;
u32 lastPlayerModelID;
// tons of crap more, don't feel like fixing this up atm
};
class dPlayerModelHandler_c {
public:
dPlayerModelHandler_c(u8 player_id); // 800D6DB0
virtual ~dPlayerModelHandler_c(); // 800D6EF0
dPlayerModelBase_c *mdlClass; // might be dPlayerModel_c ?
int loadModel(u8 player_id, int powerup_id, int unk); // 800D6EE0
void update(); // 800D6F80
void setMatrix(Mtx matrix); // 800D6FA0
void setSRT(Vec position, S16Vec rotation, Vec scale); // 800D7030
void callVF20(); // 800D70F0
void draw(); // 800D7110
private:
int hasMatrix; // might be bool ?
void allocPlayerClass(u8 player_id); // 800D6E00
};
class mTexture_c {
public:
mTexture_c(); // 802C0D20
mTexture_c(u16 width, u16 height, GXTexFmt format); // 802C0D70
// vtable is at 80350450
virtual ~mTexture_c(); // 802C0DB0
virtual void setFlagTo1(); // 802C0E20
void setImageBuffer(void *buffer); // 802C0E30
void load(GXTexMapID id); // 802C0E50
void makeTexObj(GXTexObj *obj); // 802C0E90
void flushDC(); // 802C0F10
void makeRadialGradient(); // 802C0F60 parameters unknown yet
void makeLinearGradient(int type, char size, u16 startPos, u16 endPos,
GXColor begin, GXColor end, bool startAtCenter); // 802C1120
// "type" should be enum once I figure it out
// reverse might not be accurate
void allocateBuffer(/* EGG::Heap */void *heap = 0); // 802C14D0
void plotPixel(u16 x, u16 y, GXColor pixel); // 802C1570
u16 width;
u16 height;
u8 flags;
u8 format;
u8 wrapS;
u8 wrapT;
u8 minFilter;
u8 magFilter;
private:
void *buffer;
void *myBuffer;
};
class dDvdLoader_c {
public:
dDvdLoader_c(); // 8008F140
virtual ~dDvdLoader_c(); // 8008F170
void *load(const char *filename, u8 unk = 0, void *heap = 0); // 8008F1B0
bool close(); // 8008F2B0 -- Frees command, DON'T USE THIS unless you free the buffer yourself
bool unload(); // 8008F310 -- Frees command and buffer, USE THIS
int size;
void *command; // really mDvd_toMainRam_c
void *heap; // really EGG::Heap
void *buffer;
private:
virtual void freeBuffer(); // 8008F380
void freeCommand(); // 8008F3F0
};
namespace nw4r {
namespace ut {
class CharWriter {
public:
CharWriter();
~CharWriter();
void SetupGX();
void SetFontSize(float w, float h);
void SetFontSize(float v);
float GetFontWidth() const;
float GetFontHeight() const;
float GetFontAscent() const;
float GetFontDescent() const;
// returns width
float Print(ushort character);
void PrintGlyph(float, float, float, /* nw4r::ut::Glyph const & */ void*);
void UpdateVertexColor();
private:
void SetupGXWithColorMapping(Color c1, Color c2);
public:
Color minColMapping, maxColMapping;
Color vtxColours[4];
Color topColour, bottomColour;
u32 modeOfSomeKind;
float scaleX;
float scaleY;
float posX;
float posY;
float posZ;
GXTexFilter minFilt;
GXTexFilter magFilt;
u16 completelyUnknown;
u8 alpha;
u8 isFixedWidth;
float fixedWidthValue;
/* ResFont* */ void *font;
};
// actually TextWriterBase<w>, but ...
class TextWriter : public CharWriter {
public:
TextWriter();
~TextWriter();
float GetLineHeight() const;
// left out most of these to avoid all the format string vararg bullshit
float CalcStringWidth(wchar_t const *string, int length) const;
float Print(wchar_t const *string, int length);
float CalcLineWidth(wchar_t const *string, int length);
float GetLineSpace() const;
bool IsDrawFlagSet(ulong, ulong) const;
float widthLimit;
float charSpace;
float lineSpace;
u32 tabWidth;
u32 drawFlag;
void *tagProcessor;
};
}
}
// More layout crap
// This file REALLY needs to be reorganised.
namespace nw4r {
namespace lyt {
class ResourceAccessor {
public:
ResourceAccessor();
virtual ~ResourceAccessor();
virtual void *GetResource(u32 dirKey, const char *filename, u32 *sizePtr) = 0;
virtual void *GetFont(const char *name);
};
class ArcResourceAccessor : public ResourceAccessor {
public:
ArcResourceAccessor();
~ArcResourceAccessor();
bool Attach(void *data, const char *rootDirName);
void *GetResource(u32 dirKey, const char *filename, u32 *sizePtr);
void *GetFont(const char *name);
ARCHandle arc;
u32 unk_20;
ut::LinkList list; // 0x24
char rootDirName[0x80]; // 0x30
// class ends at 0xB0
};
class AnimResource {
public:
void *fileHeader;
void *info;
void *tags;
void *share;
};
}
}
namespace m2d {
class ResAcc_c {
public:
ResAcc_c();
virtual ~ResAcc_c();
virtual void initialSetup();
nw4r::lyt::ResourceAccessor *resAccPtr; // 0x04
void *arcData; // 0x08
nw4r::lyt::ArcResourceAccessor resAcc; // 0x0C
// class ends at 0xBC
bool attachArc(void *data, const char *rootDir); // 0x801637A0
};
class ResAccLoader_c : public ResAcc_c {
public:
ResAccLoader_c();
~ResAccLoader_c();
void *buffer;
dDvdLoader_c loader; // 0xC0
// ends at 0xD4
bool loadArc(const char *path);
bool loadArc(const char *path, u8 unk);
void free();
};
class AnmResHandler_c {
public:
AnmResHandler_c();
virtual ~AnmResHandler_c();
struct Thing {
nw4r::lyt::Group *group;
nw4r::lyt::AnimTransform *animTransform;
};
nw4r::lyt::AnimResource resource; // 0x04
Thing *groups; // 0x14
u32 groupCount; // 0x18
bool load(const char *name, ResAcc_c *resAcc, nw4r::lyt::Layout *layout, bool useDiffInit);
bool free();
Thing *getThingForGroupName(const char *name); // 80164130
};
class FrameCtrl_c {
public:
virtual ~FrameCtrl_c();
float frameCount; // 0x04
float currentFrame; // 0x08
float lastFrame; // 0x0C
float speed; // 0x10; default: 1
u8 flags; // 0x14
void processAnim(); // 0x80163800
void setup(u8 flags, float frameCount, float speed, float initialFrame); // 0x801638A0
void setCurrentFrame(float frame); // 0x80163910
void setSpeed(float speed); // 0x80163920
bool isDone(); // 0x80163930
};
class Anm_c {
public:
FrameCtrl_c *frameCtrlPtr;
AnmResHandler_c *resHandler; // ? 0x04
AnmResHandler_c::Thing *thing; // 0x08
u8 flags; // 0x0C - |1 = enabled successfully?
FrameCtrl_c frameCtrl; // 0x10
// too lazy to list the methods for this atm
// after IDA reverted all the changes I made to the DB this
// afternoon ...
};
class EmbedLayoutBase_c : public Base_c {
public:
EmbedLayoutBase_c();
~EmbedLayoutBase_c();
void draw(); // don't call this directly
virtual void update();
virtual bool build(const char *brlytPath, ResAcc_c *resAcc = 0);
nw4r::lyt::Pane *getRootPane();
nw4r::lyt::Pane *findPaneByName(const char *name) const;
nw4r::lyt::TextBox *findTextBoxByName(const char *name) const;
nw4r::lyt::Picture *findPictureByName(const char *name) const;
nw4r::lyt::Pane *findWindowByName(const char *name) const;
void animate();
void calculateMtx();
nw4r::lyt::Layout layout; // 0x10 -- actually m2d::Layout_c but I'll add that later
nw4r::lyt::DrawInfo drawInfo; // 0x30
ResAcc_c *resAccPtr; // 0x84 -- a ResAcc? referenced in Build()
float posX; // 0x88
float posY; // 0x8C
float clipX; // 0x90
float clipY; // 0x94
float clipWidth; // 0x98
float clipHeight; // 0x9C
bool clippingEnabled; // 0xA0
u32 hasAnimations; // 0xA4
u32 unk_A8; // 0xA8
};
class EmbedLayout_c : public EmbedLayoutBase_c {
public:
EmbedLayout_c();
~EmbedLayout_c();
bool build(const char *brlytPath, ResAcc_c *resAcc = 0);
bool loadArc(const char *name, bool isLangSpecific);
bool loadArc(const char *name, u8 unk, bool isLangSpecific);
bool loadArcForRegion(const char *name); // uses EU/Layout/$name
// there's also a NedEU one, but should it really be listed here...?
bool free();
// does NSMBW even use consts? I have no idea. maybe not
void getPanes(const char **names, nw4r::lyt::Pane **output, int count) const;
void getWindows(const char **names, nw4r::lyt::Pane **output, int count) const; // TODO: change to others
void getPictures(const char **names, nw4r::lyt::Picture **output, int count) const;
void getTextBoxes(const char **names, nw4r::lyt::TextBox **output, int count) const;
void setLangStrings(const char **names, const int *msgIDs, int category, int count);
void loadAnimations(const char **names, int count);
void loadGroups(const char **names, int *animLinkIDs, int count);
void enableNonLoopAnim(int num, bool goToLastFrame = false);
void enableLoopAnim(int num);
void resetAnim(int num, bool goToLastFrame = false);
void disableAnim(int num);
void disableAllAnimations();
bool isAnimOn(int num = -1);
bool isAnyAnimOn();
void execAnimations();
ResAccLoader_c loader; // 0xAC
AnmResHandler_c *brlanHandlers; // 0x180
Anm_c *grpHandlers; // 0x184
bool *animsEnabled; // 0x188
int brlanCount; // 0x18C
int grpCount; // 0x190
int lastAnimTouched; // 0x194
private:
void fixTextBoxesRecursively(nw4r::lyt::Pane *pane);
};
}
extern "C" float fmod(float, float);
bool RectanglesOverlap(Vec *bl1, Vec *tr1, Vec *bl2, Vec *tr2);
/* Tilemap related stuff */
class TilemapClass {
public:
virtual ~TilemapClass();
u16 *allocatedBlocks[256];
u32 _404;
u8 blockLookup[2048];
u16 blockCount;
u32 _C0C;
u32 ts1ID, ts2ID, ts3ID, layerID, areaID, frmHeap, is2Castle;
// Only the public API is listed
u16 *getPointerToTile(int x, int y, u32 *blockNum = 0, bool unkBool = 0);
// TODO: more?
};
class BGDatClass {
public:
BGDatClass();
virtual ~BGDatClass();
u8 *bgData[4][3];
TilemapClass *tilemaps[4][3];
u8 *tsObjIndexData[4][4];
u8 *tsObjData[4][4];
char tsNames[4][4][0x20];
// this is fucked up!
// the parent heap is frmHeaps[0][0]
// each tileset's heap is frmHeaps[AREA][LAYER+1]
void *frmHeaps[4][4];
static BGDatClass *instance; // 8042A0D0
// I've only listed the public API because other stuff isn't really needed atm.
const char *getTilesetName(int area, int number);
// TODO: more?
};
struct BGRender {
u8 unk[0xC00];
u8 *objectData;
u8 _C04, _C05;
u16 _C06, _C08;
u16 blockNumber;
u16 curX, curY;
u16 tileToPlace;
u16 objDataOffset, objType, objX, objY, objWidth, objHeight;
u16 tileNumberWithinBlock, areaID;
};
// A HACK
extern void *DVDClass;
extern "C" u8 *GetRes(void *Something, const char *arcname, const char *filename);
// Use THESE instead, until I write something up for dRes or dRes_c or whatever the fuck it's called
inline u8 *getResource(const char *arcName, const char *fileName) {
return GetRes((void*)(((u8*)DVDClass)+4), arcName, fileName);
}
inline void scaleDown(Vec* scale, float amt) { scale->x -= amt; scale->y -= amt; scale->z -= amt; }
inline void scaleUp(Vec* scale, float amt) { scale->x -= amt; scale->y -= amt; scale->z -= amt; }
void ConvertStagePositionToScreenPosition(Vec2 *screen, Vec *stage);
class SoundPlayingClass /* : public something */ {
public:
// Size: 0x17C
void PlaySoundAtPosition(int id, Vec2 *pos, u32 flags); // 80198D70
static SoundPlayingClass *instance1; // 8042A03C
static SoundPlayingClass *instance2; // 8042A03C
static SoundPlayingClass *instance3; // 8042A03C
};
class dEffectBreakBase_c {
// TODO (not really needed, though)
};
class dEffectBreakMgr_c {
public:
static dEffectBreakMgr_c *instance;
dEffectBreakMgr_c();
~dEffectBreakMgr_c();
void execute();
void draw();
bool spawnTile(Vec *position, u32 settings, char param);
// Settings:
// (BlockType << 8) | (HalfSpeedFlag << 4) | (VelocityChange & 3)
//
// Types:
// 0=Brick, 1=Stone, 2=Wood, 3=Question, 4=Used
// 5=Red, 6=Used, 7=Unused, 8=Final Battle
bool spawnIcePiece(Vec *position, u32 settings, char param);
// Three more still need to be REed
private:
bool prepare(dEffectBreakBase_c *ef, Vec *pos, u32 settings, u8 param);
void cleanup();
void cleanupAll();
};
namespace EGG {
class Effect7C {
public:
virtual ~Effect7C();
virtual void clear();
u8 data[0x94];
};
class Effect {
public:
Effect(); // 802D7D90
virtual ~Effect();
char effectName[32];
u32 secondVarFromSpawnFunc;
u32 flags; // 1 = has translation, 2 = matrix was set, 4 = ?
float _2C, _30, _34;
Vec translate;
Mtx matrix;
u32 HandleBase_00, HandleBase_04;
Effect7C ef7C;
virtual bool _vf0C();
virtual void _vf10(); // related to RetireEmitterAll?
virtual void _vf14(); // also related to RetireEmitterAll?
virtual void _vf18(); // related to RetireEmitterAll and RetireParticleAll?
virtual void _vf1C(bool flag); // sets or clears some flag
virtual void _vf20(bool flag); // sets or clears another flag
virtual void _vf24(bool flag); // sets or clears both of those flags
// all these functions have a strange purpose
// _vf54 is the one sole exception to everything written below!
//
// they all call through to ef7C methods, which modify two bitfields stored in it:
// void EGG::Effect7C::modifyBitfields(u32 mask, u32 flagBit) {
// if (flagBit & 1)
// this->_04 |= mask;
// else
// this->_04 &= ~mask;
// if (flagBit & 2)
// this->_08 |= mask;
// else
// this->_08 &= ~mask;
// }
// after that, the methods set value(s) passed by the caller
virtual void _vf28(u16 unk, u32 flagBit); // flag is 1, value stored to its 0xC
virtual void _vf2C(float unk, u32 flagBit); // flag is 2, value stored to its 0x10
virtual void _vf30(u16 unk, u32 flagBit); // flag is 4, value stored to its 0x14
virtual void _vf34(u16 unk, u32 flagBit); // flag is 8, value stored to its 0x16
virtual void _vf38(char unk, u32 flagBit); // flag is 0x10, value stored to its 0x18
virtual void _vf3C(float unk, u32 flagBit); // flag is 0x20, value stored to its 0x1C
virtual void _vf40(float unk, u32 flagBit); // flag is 0x40, value stored to its 0x20
virtual void _vf44(float unk, u32 flagBit); // flag is 0x80, value stored to its 0x24
virtual void _vf48(float unk, u32 flagBit); // flag is 0x100, value stored to its 0x28
virtual void _vf4C(Vec *unk, u32 flagBit); // flag is 0x200, values stored at its 0x2C
virtual void _vf50(Vec *unk, u32 flagBit); // flag is 0x400, values stored at its 0x38
virtual void _vf54(Vec *unk);
virtual void _vf58(u8 r, u8 g, u8 b, u8 a, u32 flagBit); // flag is 0x1000, value stored to its 0x44
// this one is similar, but it stores two colours into an array at 0x48
// alpha values are ignored
// valid indices are 0 and 1 afaics?
// flag is 0x2000 << index (so, 0x2000 or 0x4000)
virtual void _vf5C(GXColor one, GXColor two, int index, u32 flagBit);
// this one sets the alpha for those colours
// flag is 0x8000 or 0x10000
virtual void _vf60(u8 one, u8 two, int index, u32 flagBit);
virtual void _vf64(Vec2 *vec, u32 flagBit); // flag is 0x20000, values stored at its 0x58
virtual void _vf68(Vec2 *vec, u32 flagBit); // flag is 0x40000, values stored at its 0x60
virtual void _vf6C(Vec *vec, u32 flagBit); // flag is 0x80000, values stored at its 0x68
virtual void _vf70(Vec *vec, u32 flagBit); // flag is 0x100000, values stored at its 0x74
// a bit of a special case: this one will set/clear 0x10000000 depending on flagBit
// but it'll also set 0x20000000 if anotherFlag is true
// if anotherFlag is false, it'll clear 0x20000000 even if flagBit is set
// values stored at ef7C's 0x80
virtual void _vf74(Vec *vec, bool anotherFlag, u32 flagBit);
virtual void _vf78(Vec *vec, u32 flagBit); // flag is 0x40000000, values stored at its 0x8C
virtual void _vf7C(Vec *one, Vec2 *two=0); // sets transformation vals and calls vf68
// stores to _2C, _30, _34
virtual void setXformValsFromParams(float one, float two, float three);
virtual void setXformValsFromVEC3(Vec *vec);
virtual void setTranslationFromVEC3(Vec *vec);
virtual void setMatrix(Mtx *mtx);
virtual void _vf90(/* ??? */); // absolutely zero idea what this does
virtual void makeItHappen(); // for internal use?
virtual void clear(); // resets all properties, etc
};
}
namespace mEf {
class effect_c : public EGG::Effect {
public:
~effect_c();
void clear();
virtual bool probablyCreateWithName(const char *name, u32 unk);
virtual bool spawn(const char *name, u32 unk, Vec *pos=0, S16Vec *rot=0, Vec *scale=0);
virtual bool spawnWithMatrix(const char *name, u32 unk, Mtx *mtx);
// these two deal with mEf::effectCB_c and crap. absolutely no idea.
virtual bool _vfA8(/* tons and tons of params */);
virtual bool _vfAC(/* a slightly smaller amount of params */);
virtual bool _vfB0(Vec *pos=0, S16Vec *rot=0, Vec *scale=0);
virtual bool _vfB4(Mtx *mtx);
};
class es2 : public effect_c {
public:
// vtable: 80329CA0
~es2();
void _vf10();
void _vf18();
void makeItHappen();
bool probablyCreateWithName(const char *name, u32 unk);
bool spawn(const char *name, u32 unk, Vec *pos=0, S16Vec *rot=0, Vec *scale=0);
bool spawnWithMatrix(const char *name, u32 unk, Mtx *mtx);
bool _vfB0(Vec *pos=0, S16Vec *rot=0, Vec *scale=0);
bool _vfB4(Mtx *mtx);
virtual u8 returnField11D(); // does exactly what it says on the tin
u32 _114, _118;
u8 _11C, _11D;
u32 _120, _124;
};
}
struct SSM { short width, height; float xScale, yScale; };
extern SSM ScreenSizesAndMultipliers[3];
extern int currentScreenSizeID;
extern float GlobalScreenWidth, GlobalScreenHeight;
void DoSceneChange(u16 name, u32 sceneSettings, u32 unk);
extern u32 GlobalTickCount;
// A hack, imported from tilesetfixer.cpp
extern void *BGDatClass, *StagePtr;
inline int GetAreaNum() {
char *st = (char*)StagePtr;
return st[0x120E];
}
class ClassWithCameraInfo {
public:
ClassWithCameraInfo();
virtual ~ClassWithCameraInfo();
// Not quite sure what this is for, stores bitflags for each tile or something?
void initBitfields();
void deinitBitfields();
void deleteOneBitfield(int area, int layer);
u16 getBitfieldPart(int area, u16 entryIndex, int layer);
void setBitfieldPart(int area, u16 entryIndex, int layer, u16 value);
void setSomeInitialVars();
void s_80082180(); // sets initedTo2 to 0, 1 or 2 depending on the X position
void s_800821E0(); // same thing for field_81
float getEffectiveScreenLeft(); // takes wrap into account
u16 *tileBitfields[12];
float _34, screenLeft, screenTop, screenWidth, screenHeight;
float screenCentreX, screenCentreY;
float _50, _54, _58, _5C, _60, _64, _68, _6C, _70, _74;
float xOffset, yOffsetForTagScroll;
u8 initedTo2, _81;
u32 _84, _88, _8C, _90;
void *bgHeap;
static ClassWithCameraInfo *instance;
// That is all
};
namespace mHeap {
extern void *archiveHeap;
extern void *commandHeap;
extern void *dylinkHeap;
extern void *assertHeap;
extern void *gameHeaps[3];
};
void WriteNumberToTextBox(int *number, const int *fieldLength, nw4r::lyt::TextBox *textBox, bool unk); // 800B3B60
void WriteNumberToTextBox(int *number, nw4r::lyt::TextBox *textBox, bool unk); // 800B3BE0
namespace EGG {
class MsgRes {
private:
const u8 *bmg, *INF1, *DAT1, *STR1, *MID1, *FLW1, *FLI1;
public:
MsgRes(const u8 *bmgFile, u32 unusedParam); // 802D7970
virtual ~MsgRes();
static void parseFormatCode(wchar_t initialTag, const wchar_t *string, u8 *outArgsSize, u32 *outCmd, const wchar_t **args); // 802D7B10
const wchar_t *findStringForMessageID(int category, int message) const; // 0x802D7B50
private:
void setBMG(const u8 *ptr); // 802D7B90
void setINF(const u8 *ptr); // 802D7BA0
void setDAT(const u8 *ptr); // 802D7BB0
void setSTR(const u8 *ptr); // 802D7BC0
void setMID(const u8 *ptr); // 802D7BD0
void setFLW(const u8 *ptr); // 802D7BE0
void setFLI(const u8 *ptr); // 802D7BF0
int identifySectionByMagic(u32 magic) const; // 802D7C00
protected:
struct INFEntry {
u32 stringOffset;
};
const INFEntry *findINFForMessageID(int category, int message) const; // 802D7C90
u32 getEntryFromMID(int index) const; // 802D7D70
};
}
namespace dScript {
class Res_c : public EGG::MsgRes {
public:
Res_c(const u8 *bmgFile, u32 unusedParam); // 800CE7F0
~Res_c();
u16 getCharScaleForMessageID(int category, int message) const; // 800CE890
u8 getFontIDForMessageID(int category, int message) const; // 800CE8C0
};
}
class MessageClass {
public:
dDvdLoader_c loader;
void *rawBmgPointer;
dScript::Res_c *msgRes;
};
dScript::Res_c *GetBMG(); // 800CDD50
void WriteBMGToTextBox(nw4r::lyt::TextBox *textBox, dScript::Res_c *res, int category, int message, int argCount, ...); // 0x800C9B50
extern "C" dAc_Py_c* GetSpecificPlayerActor(int number);
extern "C" dStageActor_c *CreateActor(u16 classID, int settings, Vec pos, char rot, char layer);
extern "C" dStageActor_c *Actor_SearchByID(u32 actorID);
struct DoSomethingCool {
u32 unk_01; //0000
Vec3 pos; //0004
Vec3 scale; //0010
f32 unk_02; //001C
f32 unk_03; //0020
f32 unk_04; //0024
f32 unk_05; //0028
f32 unk_06; //002C
f32 unk_07; //0030
f32 unk_08; //0034
f32 unk_09; //0038
};
extern "C" u8 dSprite_c__getXDirectionOfFurthestPlayerRelativeToVEC3(dEn_c *, Vec pos);
extern "C" void *ShakeScreen(void *, unsigned int, unsigned int, unsigned int, unsigned int);
extern "C" void *PlaySound(dStageActor_c *, int soundID);
extern "C" void *PlaySoundAsync(dStageActor_c *, int soundID);
extern "C" u32 GetActivePlayerCount();
#include "newer.h"
class BGGMEffectRenderer : public m3d::proc_c {
private:
u32 effectGroupID;
public:
~BGGMEffectRenderer();
void drawOpa();
void drawXlu();
virtual bool setupEffectRenderer(mAllocator_c *allocator, int opaPrio, int xluPrio, int groupID);
};
void CleanUpEffectThings();
bool FreeEffects(int efNum);
bool FreeBreff(int efNum);
bool FreeBreft(int efNum);
#endif
|